linsolve with symmetric property set is slower than without
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I want to improve the performance of solving a system of linear equations Ax=b. I have a symmetric A matrix. This matrix and the corresponding b-Vector are changing each iteration.
for it=1:600
% just to demonstrate, that A and b are changing every iteration
A = funA(x);
b = funb(x);
t1 = tic();
sol = A\b;
tmldivide(it) = toc(t1);
LSopts.POSDEF = false;
LSopts.SYM = true;
t1 = tic();
sol1 = linsolve(A, b, LSopts);
tlinsolve1(it) = toc(t1);
LSopts.POSDEF = false;
LSopts.SYM = false;
t1 = tic();
sol2 = linsolve(A, b, LSopts);
tlinsolve2(it) = toc(t1);
end
The sum and mean elapsed times are as follows
sum(tmldivide): 0.715083
sum(tlinsolve1): 0.616885
sum(tlinsolve2): 0.35114
mean(tmldivide): 0.001135052380952
mean(tlinsolve1): 9.791825396825392e-04
mean(tlinsolve2): 5.573650793650793e-04
The solutions sol and sol1 are identical. The error between sol and sol2 are very small (in the range of 1e-14). My question is now, why is linsolve faster if I say, that the matrix is not symmetric even though it is a symmetric matrix. Shouldn't it be more efficient if I spcify the properties correctly? Another question would be, if there is a way to speed the solving of the Ax=b up even further?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!