The LU decomposition of a square matrix A is P A= L U, where P is a permutation matrix, L is lower triangular with 1s on the diagonal, and U is upper triangular. The lu command finds the LU decomposition of a matrix.
The permutation matrix P is defined from p by:
| Pi,p(i)=1, Pi,j=0 if j ≠ p(i) |
In other words, it is the identity matrix where the rows are permuted according to the permutation p. You can get the permutation matrix from p by P:=permu2mat(p) (see Section 6.9.6).
Example.
Input:
| A := [[3.,5.],[4.,5.]]:; |
| (p,L,U):=lu(A) |
Output:
| ⎡ ⎣ | 1,0 | ⎤ ⎦ | , | ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ | , | ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ |
Here n=2, hence:
| P[0,p(0)]=P2[0,1]=1, P[1,p(1)]=P2[1,0]=1, P=[[0,1],[1,0]] |
Verification:
Input:
Output:
| ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ | , | ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ |
Note that the permutation is different for exact input (the choice of
pivot is the simplest instead of the largest in absolute value).
Input:
Output:
| ⎡ ⎣ | 0,1 | ⎤ ⎦ | , | ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ | , | ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ |
Input:
Output:
| ⎡ ⎣ | 1,0 | ⎤ ⎦ | , | ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ | , | ⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ |