I'm trying to solve a system of differential equations involving variational inequalities. I'm currently using the LCP solver in LCPsolve.jl. I've profiled my code and found that the bottleneck is in lines 216-219 here. More specifically, the profiler highlights the multiplication and sum in:
H = Jk'*Jk + μ*I
where Jk
is a sparse matrix with size that varies within the for
loop (but always smaller than 150x150) and
typeof(Jk) = SparseMatrixCSC{Float64, Int64}
typeof(μ) = Float64
It also seems that those steps also allocate memory. The other operation highlighted by the profiler is
-(cholesky(H)\Jphi)
where
typeof(H) = SparseMatrixCSC{Float64, Int64}
typeof(Jphi) = Vector{Float64}
Is there a way to improve the performance and/or memory allocation of those steps? Thank you!
qr
. However, I'm not getting the same results when H is a sparse matrix. Here is what I mean:A = rand(100,100); b = rand(100); x1 = A\b; Q, R = qr(A); x2 = inv(factorize(R))*(Q'*b); isapprox(x1, x2); A = sprand(100,100,0.1); b = rand(100); x1 = A\b; aux = qr(A); x2 = inv(factorize(aux.R))*(aux.Q'*b); isapprox(x1, x2);
In the second case with sparse matrix A, i'm not getting the same result. So I don't know how to implement your suggestion.