lu
LU matrix factorization.
📝Syntax
[L, U] = lu(A)
[L, U, P] = lu(A)
📥Input Arguments
Parameter Description
A a matrix: square, finite single or double, real or complex, dense or sparse.
📤Output Arguments
Parameter Description
L Lower triangular factor: matrix (same type A)
U Upper triangular factor: matrix (same type A).
P Row permutation: matrix (same type A).
📄Description

[L, U] = lu(A) function decomposes a full matrixA into two matrices: an upper triangular matrixU and a permuted lower triangular matrix L.

This factorization satisfies the equation A = L * U.

[L, U, P] = lu(A) function, when used with three output arguments, provides a permutation matrixP in addition to the unit lower triangular matrixL and the upper triangular matrix U.

This factorization is expressed as A = P'LU, where L is unit lower triangular, and U is upper triangular.

Sparse double, single, complex double, and complex single matrices are supported. Sparse factors keep sparse storage and keep the input numeric class where applicable.

💡Examples
A = magic(5)
[L, U] = lu(A)
L * U
A = magic(5)
[L, U, P] = lu(A);
subplot(1, 2, 1)
spy(L)
title(_('L factor'))
subplot(1, 2, 2)
spy(U)
title(_('U factor'))
Example illustration
Sparse single LU factorization.
A = sparse(single([4 1; 2 3]));
[L, U, P] = lu(A)
🔗See Also
cond
Used Functions
LAPACK dgetrf, LAPACK sgetrf, LAPACK zgetrf, LAPACK cgetrf
🕔Version History
Version Description
1.1.0 initial version
2.0.0 added sparse single and complex single factorization support
Edit this page on GitHub