Is it possible to speed up the calculation of large sparse matrices, for example. optimal brackets?
I ask: can I speed up the following code by forcing Matlab to perform operations in the specified order (for example, from right to left or something like that)?
I have a sparse square symmetric matrix H that was previously factorized, and a sparse vector M with a length equal to dimension H. What I want to do is this:
EDIT:. Additional information: H usually 4000x4000. The calculations of z and c are performed approximately 4000 times, while the calculation of dVa and dVaComp is performed 10 times for every 4000 cycles, thus 40,000. (DVa and dVaComp are solved iteratively, where P_mis is updated).
Here M*c*M' , will become a sparse matrix with 4 nonzero entries. In Matlab:
[LUP] = lu(H); % H is sparse (thus also L, U and P) % for i = 1:4000 % Just to illustrate M = sparse([bf bt],1,[1 -1],n,1); % Sparse vector with two non-zero elements in bt and bf z = -M'*(U \ (L \ (P * M))); % M^t*H^-1*M = a scalar c = (1/dyp + z)^-1; % dyp is a scalar % while (iterations < 10 && ~=converged) dVa = - (U \ (L \ (P * P_mis))); dVaComp = (U \ (L \ (P * M * c * M' * dVa))); % Update P_mis etc. % end while % end for
And for the record: Despite the fact that I use the inversion of H many times, it does not accelerate its preliminary calculation.
Thanks =)
source share