Compute the LU decomposition of a. If a is full subroutines from Lapack are used and if a is sparse then UMFPACK is used. The result is returned in a permuted form, according to the optional return value p. For example, given the matrix
a = [1, 2; 3, 4]
,[l, u, p] = lu (a)returns
l = 1.00000 0.00000 0.33333 1.00000 u = 3.00000 4.00000 0.00000 0.66667 p = 0 1 1 0The matrix is not required to be square.
Called with two or three output arguments and a spare input matrix, then lu does not attempt to perform sparsity preserving column permutations. Called with a fourth output argument, the sparsity preserving column transformation Q is returned, such that p
*
a*
q=
l*
u.Called with a fifth output argument and a sparse input matrix, then lu attempts to use a scaling factor r on the input matrix such that p
* (
r\
a) *
q=
l*
u. This typically leads to a sparser and more stable factorsation.An additional input argument thres, that defines the pivoting threshold can be given. thres can be a scalar, in which case it defines UMFPACK pivoting tolerance for both symmetric and unsymmetric cases. If thres is a two element vector, then the first element defines the pivoting tolerance for the unsymmetric UMFPACK pivoting strategy and the second the symmetric strategy. By default, the values defined by
spparms
are used and are by default[0.1, 0.001]
.Given the string argument 'vector', lu returns the values of p q as vector values, such that for full matrix, a
(
p,:) =
l*
u, and r(
p,:) *
a(:,
q) =
l*
u.With two output arguments, returns the permuted forms of the upper and lower triangular matrices, such that a
=
l*
u. With one output argument y, then the matrix returned by the Lapack routines is returned. If the input matrix is sparse then the matrix l is embedded into u to give a return value similar to the full case. For both full and sparse matrices, lu looses the permutation information.