<< linalg_expm Linalg linalg_factorlupivot >>

Linalg >> Linalg > linalg_factorlu

linalg_factorlu

Computes the LU decomposition without pivoting.

Calling Sequence

[L, U] = linalg_factorlu ( A , verbose )

Parameters

A :

a n-by-n matrix of doubles

verbose :

a 1-by-1 matrix of boolean, set to true to display intermediate messages

L :

a n-by-n matrix of doubles, lower triangular.

U :

a n-by-n matrix of doubles, upper triangular.

Description

Decomposes A as A = L*U with L lower triangular and unit diagonal, U upper triangular and non-unit diagonal. This algorithm might be sensitive to inaccuracies if A near singular. There is no solution is A is singular. The algorithm might be unstable, even if A is not ill-conditionned. Indeed, it might produce large entries in L and U, even if entries in A are of moderate size. Uses an effective algorithm with vectorization.

Examples

// Basic test
A=[
1 1 1 1 1
1 2 2 2 2
1 2 3 3 3
1 2 3 4 4
1 2 3 4 5
];
[L,U]=linalg_factorlu(A,%f)
Lexpected=[
1 0 0 0 0
1 1 0 0 0
1 1 1 0 0
1 1 1 1 0
1 1 1 1 1
];
Uexpected=[
1 1 1 1 1
0 1 1 1 1
0 0 1 1 1
0 0 0 1 1
0 0 0 0 1
];

// Combine factorlu and solvelu
A=[
1 1 1 1 1
1 2 2 2 2
1 2 3 3 3
1 2 3 4 4
1 2 3 4 5
];
b=[5;9;12;14;15];
[L,U]=linalg_factorlu(A,%f)
x=linalg_solvelu(L,U,b,%f)
xexpected=[1;1;1;1;1]

// A difficult case: pivoting is necessary
A=[
1.d-8 1
1     1
];
[L,U]=linalg_factorlu(A,%f)
Lexpected=[
1.   0
1.d8 1.]
Uexpected=[
1.d-8  1
0.    -1.d8+1
]
cond(A) // 2.6180340238745070102766
cond(L) // 9999999949752408.
cond(U) // 9999999900000000.

Authors

<< linalg_expm Linalg linalg_factorlupivot >>