Difference between mldivide and lsqr
14 ビュー (過去 30 日間)
古いコメントを表示
Hi, I am curious about the difference between mldivide and lsqr.
Both seem to be used for calculating x where A*x=b.
Thank you in advance.
0 件のコメント
採用された回答
Bruno Luong
2023 年 7 月 21 日
編集済み: Bruno Luong
2023 年 7 月 21 日
A=rand(3,5)
b=rand(3,1)
The backslash returns a solution with most 0s and lsqr returns solution with minimum l2-norm.
xbackslash=A\b
xlsqr=lsqr(A,b)
xminnorm=lsqminnorm(A,b)
A*xbackslash
A*xlsqr
norm(xbackslash)
norm(xlsqr) % smaller even xlsqr has no O
On the runtime the backslash is usualy faster, at least for dense matrix.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Particle & Nuclear Physics についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!