Computes the LU decomposition with pivoting.
[L, U, P] = linalg_factorlupivot ( A ) [L, U, P] = linalg_factorlupivot ( A , verbose )
a n-by-n matrix of doubles
a 1-by-1 matrix of boolean (default verbose=%f), set to %t to display intermediate messages
a n-by-n matrix of doubles, lower triangular.
a n-by-n matrix of doubles, upper triangular.
a n-by-n matrix of doubles, with 0 or 1 entries
Decomposes A as P*A = L*U with L lower triangular and unit diagonal, U upper triangular and non-unit diagonal, P a permutation matrix with 0/1 entries. This algorithm might be sensitive to inaccuracies if A near singular. There is no solution is A is singular. If A is not ill-conditionned, the algorithm is accurate. Uses an effective algorithm with vectorization.
A=[ 1.d-8 1 1 1 ]; [L,U,P]=linalg_factorlupivot(A) Lexpected=[ 1. 0 1.d-8 1. ] Uexpected=[ 1 1 0 1 - 1.d-8 ] Pexpected=[ 0 1 1 0 ] // See what happens [L,U,P]=linalg_factorlupivot(A,%t) // See the algorithm edit linalg_factorlupivot | ![]() | ![]() |