|
5.1.84 ludecomp
Syntax:
ludecomp ( matrix_expression )
Type:
- list
Purpose:
- Computes the LU-decomposition of an (m x n) matrix.
The matrix, A say, must consist of numbers, only. This means that
when the basering represents some
,then all entries of A must come from the ground field K.
The LU-decomposition of A is a triple of matrices P, L, and U such that
- P * A = L * U,
- P is an (m x m) permutation matrix, i.e., its rows/columns form the
standard basis of K^m,
- L is an (m x m) matrix in lower triangular form with all diagonal
entries equal to 1, and
- U is an (m x n) matrix in upper row echelon form.
From these conditions, it easily follows that also A = P * L * U holds,
since P is self-inverse.
list L=ludecomp(A); fills a list L with the three above entries
P, L, and U.
Example:
| ring r=0,(x),dp;
matrix A[3][4]=1,2,3,4,1,1,1,1,2,2,1,1;
list plu = ludecomp(A);
print(plu[3]); // the matrix U of the decomposition
==> 1,2, 3, 4,
==> 0,-1,-2,-3,
==> 0,0, -1,-1
print(plu[1]*A-plu[2]*plu[3]); // should be the zero matrix
==> 0,0,0,0,
==> 0,0,0,0,
==> 0,0,0,0
|
See
luinverse.
|