linsolve with symmetric property set is slower than without
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!