speed up run time of mldivide function.
6 views (last 30 days)
Show older comments
Hi,
I am calling mldivide function about 10^7 times:
my syntax looks this way:
C=mldivide(A,B);
where both A,B are sparse matrices. size(A)=2^10*2^10 and size(B)=(1x2^10) (Assume that my matrix A has ~2^12 non zero data points ~95% of them close to center diagonal.A is a lower traingular matrix)
After using the profile command ,when i run the code, i found it takes 60-70% of total time(~2000 secs) in that particular line.(My computer specs are i5, 8gb ram, matlab 2018b)
can i make mldivide compute any faster? (assume that I can only use sparse matrices, and assume that i want to run it on my computer.).
Unfortunately, GPU computing of mldivide using sparse matrice does not seem to work so well. If you can, please comment on using 'GPU computing with (mldivide + sparse matrices)' as well..
0 Comments
Accepted Answer
Steven Lord
on 23 Nov 2018
If you're solving the system A*x = b with the same A every time (or a small number of different A matrices many times each) try creating a decomposition and reusing that decomposition each time.
8 Comments
Bruno Luong
on 28 Nov 2018
Edited: Bruno Luong
on 28 Nov 2018
Matrix upper/lower triangular does not need to de factorized since back-substution can work directly with original matrix. So it's normal decomposition, lu, chol or friends won't help (they actually do nothing more than factorizing a general matrix of two or more triangulars/permutation matrices, which in your case reduce nothing).
You might want to program your own back-substitution in MEX if the structure of your matrix is special. But I doubt you'll beat MATLAB.
I think what you ask is impossible,just buy a faster machine.
More Answers (2)
Bruno Luong
on 23 Nov 2018
You might want to use iterative method.
7 Comments
Bruno Luong
on 27 Nov 2018
A = sparse(eye(10000));
b = randn(length(A),1);
A(:,1)=A(:,1)+b;A(1,1)=1;
A(:,2)=A(:,2)+b;A(2,2)=1;A(1,2)=0;
A(:,3)=A(:,3)+b;A(3,3)=1;A(1,3)=0;A(2,3)=0;
Such matrix is special, you can just the solution by splitting in blocks of
A(1:3,1:3), A(4:end,1:3) and A(4:end,4:end)
Solutions are reduce to 3x3 inversion.
Again if you are not willing to tell us more about your matrix, we can only guess the best way to make the resolution. This can take forever.
James Tursa
on 26 Nov 2018
Edited: James Tursa
on 26 Nov 2018
You might want to take a look at the Tim Davis Factorize FES submission:
See Also
Categories
Find more on Performance and Memory in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!