|
|
◆ Dgetrf()
| Sub Dgetrf |
( |
M As |
Long, |
|
|
N As |
Long, |
|
|
A() As |
Double, |
|
|
IPiv() As |
Long, |
|
|
Info As |
Long |
|
) |
| |
LU factorization of a general matrix
- Purpose
- This routine computes an LU factorization of a general m x n matrix A using partial pivoting with row interchanges. The factorization has the form where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
This is the right-looking Level 3 BLAS version of the algorithm.
- Parameters
-
| [in] | M | Number of rows of the matrix A. (M >= 0) (If M = 0, returns without computation) |
| [in] | N | Number of columns of the matrix A. (N >= 0) (If N = 0, returns without computation) |
| [in,out] | A() | Array A(LA1 - 1, LA2 - 1) (LA1 >= M, LA2 >= N)
[in] M x N matrix to be factored.
[out] Factors L and U from the factorization A = P*L*U. The unit diagonal elements of L are not stored. |
| [out] | IPiv() | Array IPiv(LIPiv - 1) (LIPiv >= min(M, N))
Pivot indices; for 1 <= i <= min(M, N), row i of the matrix was interchanged with row IPiv(i-1). |
| [out] | Info | = 0: Successful exit.
= -1: The argument M had an illegal value. (M < 0)
= -2: The argument M had an illegal value. (N < 0)
= -3: The argument A() is invalid.
= -4: The argument IPiv() is invalid.
= i > 0: The i-th diagonal element of the factor U is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations. |
- Reference
- LAPACK
- Example Program
- Solve the system of linear equations Ax = B and estimate the reciprocal of the condition number (RCond) of A, where
( 0.2 -0.11 -0.93 ) ( -0.3727 )
A = ( -0.32 0.81 0.37 ), B = ( 0.4319 )
( -0.8 -0.92 -0.29 ) ( -1.4247 )
Sub Ex_Dgetrf()
Const N = 3
Dim A(N - 1, N - 1) As Double, B(N - 1) As Double, IPiv(N - 1) As Long
Dim ANorm As Double, RCond As Double, Info As Long
A(0, 0) = 0.2: A(0, 1) = -0.11: A(0, 2) = -0.93
A(1, 0) = -0.32: A(1, 1) = 0.81: A(1, 2) = 0.37
A(2, 0) = -0.8: A(2, 1) = -0.92: A(2, 2) = -0.29
B(0) = -0.3727: B(1) = 0.4319: B(2) = -1.4247
ANorm = Dlange("1", N, N, A())
Call Dgetrf(N, N, A(), IPiv(), Info)
If Info = 0 Then Call Dgetrs("N", N, A(), IPiv(), B(), Info)
If Info = 0 Then Call Dgecon("1", N, A(), ANorm, RCond, Info)
Debug.Print "X =", B(0), B(1), B(2)
Debug.Print "RCond =", RCond
Debug.Print "Info =", Info
End Sub
Function Dlange(Norm As String, M As Long, N As Long, A() As Double, Optional Info As Long) As Double One norm, Frobenius norm, infinity norm, or largest absolute value of any element of a general rectan...
Sub Dgetrf(M As Long, N As Long, A() As Double, IPiv() As Long, Info As Long) LU factorization of a general matrix
Sub Dgecon(Norm As String, N As Long, A() As Double, ANorm As Double, RCond As Double, Info As Long) Condition number of a general matrix
Sub Dgetrs(Trans As String, N As Long, A() As Double, IPiv() As Long, B() As Double, Info As Long, Optional Nrhs As Long=1) Solution to LU factorized system of linear equations AX = B or ATX = B for a general matrix
- Example Results
X = 0.86 0.64 0.51
RCond = 0.232708473186076
Info = 0
|