Performs LU Decomposition of the current matrix object.
MatrixObject.LU L, U, PermIndex, PermSign
LU decomposition is not possible for a singular matrix.
Partial pivoting is used, so that L x U matrix product returns the initial matrix with rows permutated according to the row permutation index which is returned in parameter PermIndex.
Error 1305 will be returned if the matrix is not square.
Error 1313 will be returned if the the decomposition is not possible due to the matrix being singular.
This example demonstrates the use of LU method.
Private Sub MatrixLU()
Dim A As Matrix, L As Matrix, U As Matrix, R As Matrix
Dim permIndex, pSign As Long
'first we creare a new matrix and we
'fill it with random values
Set A = New Matrix
A.Size 5, 5
A.FillRandom
'and we print it
Debug.Print "A= "
Debug.Print A.GetString
'then we perform the LU decomposition
'perIndex() will return the row exchanges
Set L = New Matrix
Set U = New Matrix
A.LU L, U, permIndex, pSign
'and we print the results
Debug.Print "L="
Debug.Print L.GetString
Debug.Print "U="
Debug.Print U.GetString
'now we verify the results finding
'the product R = LxU
Set R = L.Times(U)
'and we rearrange rows using
'the permutation index
R.ReorderRows permIndex
Debug.Print "R=LxU"
Debug.Print R.GetString
'please notice that R equals to
'original matrix
End Sub
Debug.Print "L2="
Debug.Print L2.GetString
'please notice that L2 equals matrix L
'
End Sub
A= | 6.000 2.000 8.000 6.000 5.000 | | 4.000 9.000 8.000 7.000 2.000 | | 9.000 7.000 5.000 3.000 0.000 | | 1.000 4.000 1.000 2.000 10.000 | | 4.000 1.000 0.000 0.000 4.000 | L= | 1.000 0.000 0.000 0.000 0.000 | | 0.444 1.000 0.000 0.000 0.000 | | 0.667 -0.453 1.000 0.000 0.000 | | 0.444 -0.358 -0.021 1.000 0.000 | | 0.111 0.547 -0.373 1.217 1.000 | U= | 9.000 7.000 5.000 3.000 0.000 | | 0.000 5.889 5.778 5.667 2.000 | | 0.000 0.000 7.283 6.566 5.906 | | 0.000 0.000 0.000 0.834 4.839 | | 0.000 0.000 0.000 0.000 5.217 | R=LxU | 6.000 2.000 8.000 6.000 5.000 | | 4.000 9.000 8.000 7.000 2.000 | | 9.000 7.000 5.000 3.000 0.000 | | 1.000 4.000 1.000 2.000 10.000 | | 4.000 1.000 0.000 0.000 4.000 |