Skip to content

lu

LU decomposition (with partial pivoting).

[L, U] = lu(A)
[L, U, P] = lu(A)
[L, U, P, Q] = lu(A) % sparse only
Y = lu(A) % packed compact form

Decomposes A into a lower-triangular L, upper-triangular U, and permutation P such that P*A = L*U. With two outputs, returns L and U such that L*U = A and L is permuted-lower (psychologically lower).

For sparse matrices, an additional column-permutation Q and a row-scaling R may be returned. The single-output form returns the LU factors packed into one matrix (LAPACK packed storage).

A = [1 2 3; 4 5 6; 7 8 10];
[L, U] = lu(A);
norm(L*U - A) % near-zero
  • chol — Cholesky factorization of a Hermitian positive-definite matrix.
  • qr — QR decomposition.
  • linsolve — Solve a linear system with optional structure hints.
  • inv — Matrix inverse.