luLU decomposition
In the following,
where
💡 A unit triangular matrix
has all of its diagonal elements equal to 1, i.e., .
Let
where
The matrix
where
Y = lu(A)Y = lu(A, perm)A is a numeric (non-character) matrix, which can be real or complex.Y = lu(A) returns a matrix Y which has the same size as A. Elements on and above the main diagonal of Y are equal to the corresponding elements in Y are equal to the corresponding elements in perm should be either 'vector' or 'matrix'. However, perm has not effect here and will be ignored. Hence, Y = lu(A, perm) and Y = lu(A) give the same results regardless of perm's value.[PtL, U] = lu(A)[PtL, U] = lu(A, perm)A is a numeric (non-character) matrix, which can be real or complex.PtL and U, which correspond to PtL * U == A.perm should be either 'vector' or 'matrix'. However, perm has not effect here and will be ignored. Hence, [PtL, U] = lu(A, perm) and [PtL, U] = lu(A) give the same results regardless of perm's value.[L, U, P] = lu(A)[L, U, P] = lu(A, 'matrix')[L, U, e] = lu(A, 'vector')A is a numeric (non-character) matrix, which can be real or complex.
If 'matrix' is used, L, U and P correspond to matrices
If 'vector' is used, e is a vector containing information about the permutation used in the decomposition. To convert e to a permutation matrix Q, we can do the following
Q = zeros(size(A,1));
for r = 1:size(A,1)
Q(r,e(r)) = 1;
end
After the above conversion, L, U and Q correspond to
[L,U,P] = lu(A) and [L,U,P] = lu(A,'matrix') give the same results.
lu.% Randomly generated matrix
a = randi(10,4,5);
% P contains permutation information
[L,U,e] = lu(a,'vector');
% Construct a permuation matrix Q using e
Q = zeros(size(a,1));
for r = 1:size(a,1)
Q(r,e(r)) = 1;
end
% Permutation matrix T given by lu with type equal to 'matrix'
[L,U,T] = lu(a,'matrix');
% Permutation matrices Q and T are the same
Q
T
Q =
0.000 0.000 0.000 1.000
1.000 0.000 0.000 0.000
0.000 0.000 1.000 0.000
0.000 1.000 0.000 0.000
T =
0.000 0.000 0.000 1.000
1.000 0.000 0.000 0.000
0.000 0.000 1.000 0.000
0.000 1.000 0.000 0.000
Y are equal to U, and elements below the main diagonal of Y are equal to L.A = randi(10,3,5);
[L,U,P] = lu(A);
Y = lu(A);
L
U
Y
L =
1.000 0.000 0.000
0.700 1.000 0.000
0.600 -0.235 1.000
U =
10.00 7.000 6.000 5.000 8.000
0.000 5.100 3.800 3.500 -0.600
0.000 0.000 -0.706 6.824 -3.941
Y =
10.00 7.000 6.000 5.000 8.000
0.700 5.100 3.800 3.500 -0.600
0.600 -0.235 -0.706 6.824 -3.941
% Generate a random matrix
A = rand(6,4);
% LU decomposition
[L,U] = lu(A);
% L*U and A are (apprxoimately) identical
L*U-A
ans = 1e-16 ×
0.000 1.110 1.110 0.278
1.110 0.000 0.000 0.000
0.069 0.000 0.000 -0.278
0.000 -0.278 0.000 0.000
0.000 0.000 0.000 0.000
0.000 0.555 -0.278 0.000