I have a long vector V and a large matrix M. My purpose is in the Julia code below.
using LinearAlgebra function myfunction(M,V) n = size(V,1) sum = 0 summ = 0 for i = 1:n-1 for j = i+1:n a= [i,j] Y = V[a] X = M[a,a] sum += Y'*inv(X)*Y summ += tr(X)*Y'*Y end end return sum, summ end
M = randn(10000,10000) V = randn(10000) @time myfunction(M,V)
Since the vector is very long and the matrix is very large, this procedure takes a long time. I spent a long time on this issue. I really appreciate your help!