mldivide (backslash): advantage by using sparse matrix instead of a full matrix with respect to the quality of the results?

6 ビュー (過去 30 日間)
I am solving a linear system of equations Ax = B with the backslash operator. I have two versions of A implemented: a sparse and a full matrix.
Sometimes I get the warning that my matrix is close too singular. However, I get it more seldom if I am using sparse matrices. Is there a reason for it? Does this mean that the results are more reliable using sparse matrices?
When I compute the condition number for both cases using the command condest(A), I obviously get the same result for the sparse and the full matrix. I have an example where condest(A) = 3.65e27 which is of course very high. However, I get only a warning that the matrix is close too singular in the case of the full matrix. Does this make sense? Can I conclude that the solution is better for the sparse matrix since I do not get a warning?
  1 件のコメント
Torsten
Torsten 2022 年 1 月 13 日
編集済み: Torsten 2022 年 1 月 13 日
Just computing the residual A*X - B should answer your question.
I can't imagine that the reliability depends on whether you use the sparse or full option.
Maybe the internal limit to give a warning is differently implemented.

サインインしてコメントする。

採用された回答

Christine Tobler
Christine Tobler 2022 年 1 月 13 日
The condition estimate used in mldivide to decide if a warning should be given is much less accurate for the sparse case. This is simply because it could get very expensive to compute in the sparse case, so we use a cheap heuristic.
So for sparse matrices, the result from condest should be trusted much more than whether a warning is given in mldivide.

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2022 年 1 月 13 日
編集済み: Bruno Luong 2022 年 1 月 13 日
If your condition is 3.65e27 you wi=on't get any reliable solution regardless the method.
The full matrix use QR with permutation and detect the conditioning issue better than sparse. MATLAB try to prevent sparse structure so it might not detect as well conditioning issue.
No I disagree with Torsen, for ill conditining system you can get wrong result even if the residual norm |A*x-b| is small. I can also guess the residual is smaller if you use full-sover, but it doesn't mean the solution is good.
  7 件のコメント
Michael Loibl
Michael Loibl 2022 年 1 月 14 日
Thank you. I won some new insights. Thank you very much for the illustrative example.
I was aware that a condition number of 1e27 is very bad. Before I thougt that I could simply trust the warnings from Matlab and lean back. When I started computing with sparse matrices, I often did not get warnings, but I started checking for the conditioning by myself. In consequence, I will add a check for the conditioning by myself now for the sparse case.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by