필터 지우기
필터 지우기

solving linear equations in a loop

조회 수: 2 (최근 30일)
Krzysztof
Krzysztof 2014년 3월 21일
편집: Matt J 2014년 3월 21일
The documentation for inv says:
A frequent misuse of inv arises when solving the system of linear equations Ax = b. One way to solve this is with x = inv(A)*b. A better way, from both an execution time and numerical accuracy standpoint, is to use the matrix division operator x = A\b.
The above taken for granted, is it nevertheless reasonable to precalculate invA = inv(A) in front of a loop containing (A\Xi), especially one that necessarily sequential?

채택된 답변

Matt J
Matt J 2014년 3월 21일
편집: Matt J 2014년 3월 21일
No. Make the different Xi the columns of matrix, X and just do A\X.
  댓글 수: 2
Krzysztof
Krzysztof 2014년 3월 21일
In case you did not have time to have a look at the algorithm: X(i+1) depends on A\X(i).
Matt J
Matt J 2014년 3월 21일
편집: Matt J 2014년 3월 21일
Probably better, then to pre-compute the LU decomposition
[L,U]=lu(A);
and then solve the system for each Xi using (U\(L\Xi)). You might improve things still further with an L,U,P decomposition.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by