I tried 3 methods to solve the system for inv(A), where A is highly sparse matrix spy(A) is given below:
1) pinv(A)......... Matlab solve it in 190 sec without any warnings.
2) A\b............. Matlab took only 10 sec but gives warning "Matrix is singular to working precision"
3) [L,U]=lu(A); inv(L)*inv(U) .......... Matlab took 50 sec but give the same warning as in 2nd method.
Is there anyway, I can get inv(A) without warnings.

댓글 수: 3

Stephen23
Stephen23 2017년 7월 27일
편집: Stephen23 2017년 7월 27일
Did you read the inv documentation? It states: "It is seldom necessary to form the explicit inverse of a matrix. A frequent misuse of inv arises when solving the system of linear equations Ax = b. One way to solve the equation is with x = inv(A)*b. A better way, from the standpoint of both execution time and numerical accuracy, is to use the matrix backslash operator x = A\b. This produces the solution using Gaussian elimination, without explicitly forming the inverse. See mldivide for further information."
So really the best answer to your question is to stop using inv. Using inv is almost always the wrong way to solve a problem.
Jan
Jan 2017년 7월 27일
편집: Jan 2017년 7월 27일
@Asif Arshid: What is your question? You observed that the slash operator has a different sensitivity to detect near to singular matrices than lu and inv(L)*inv(U). What is the condition number of the matrix? Do you think that slash is to pessimistic or the lu method too sloppy? Or are you surprised by the speed of the slash operator?
Asif Arshid
Asif Arshid 2017년 7월 27일
@Stephen: I tried "mldivide", but its gives warning of "Matrix is singular to working precision".
@Jan: my question is, I need to solve my system for "x" in less time than "pinv" (190 sec). The condition number is 4.7167e+17.

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2017년 7월 27일

0 개 추천

Use the lsqr (link) or similar function to solve sparse matrix problems.

댓글 수: 4

Asif Arshid
Asif Arshid 2017년 7월 27일
Thanks @Star for your suggestions, but its also not working for me.
It says, "lsqr stopped at iteration 20 without converging to the desired tolerance 1e-06 because the maximum number of iterations was reached. The iterate returned (number 20) has relative residual 1."
Walter Roberson
Walter Roberson 2017년 7월 27일
The 4th parameter to lsqr() allows you to specify a higher number of iterations.
Star Strider
Star Strider 2017년 7월 27일
@Walter — Thank you.
M.Shaarawy
M.Shaarawy 2019년 5월 20일
Is there regularized parameterized trust region sub problem (RPTRS) in MATLAB to solve this kind of problem?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

질문:

2017년 7월 27일

댓글:

2019년 5월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by