ilu

Incomplete LU factorization of a sparse matrix.

Category: Mathematics > Sparse Matrices

Syntax

[L, U] = ilu(A)

Returns sparse triangular factors with the nonzero pattern of A, so that L*U approximates A.

[L, U] = ilu(A, opts)

Chooses the variant with a struct: type is 'nofill', 'crout' or 'ilutp', with droptol for the last two.

LU = ilu(A)

Returns the two factors packed in one matrix (L without its unit diagonal, plus U).

Description

An exact LU factorization of a sparse matrix usually fills in many zeros. ilu keeps the factors sparse by dropping entries, either those outside the original pattern ('nofill') or those smaller than a tolerance ('crout', 'ilutp'). L*U is then only close to A, which is exactly what is wanted for a preconditioner.

Pass L and U as M1 and M2 to gmres, bicgstab and the other iterative solvers.

Input arguments

A
Sparse square matrix.
opts
Struct with type and, for 'crout' and 'ilutp', droptol, a threshold below which entries are dropped.

Output arguments

L
Unit lower triangular factor.
U
Upper triangular factor.

Example

Preconditioning bicgstab

A = sparse(diag(4*ones(5,1)) + diag(ones(4,1),1) + diag(ones(4,1),-1));
[L, U] = ilu(A);
full(U)
b = (1:5)';
[x, flag] = bicgstab(A, b, 1e-10, 50, L, U);
flag
Output
ans = 5×5

    4.0000    1.0000         0         0         0
         0    3.7500    1.0000         0         0
         0         0    3.7333    1.0000         0
         0         0         0    3.7321    1.0000
         0         0         0         0    3.7321
flag = 0

See also

ichol lu gmres bicgstab