XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Dgttrf()

Sub Dgttrf ( N As  Long,
Dl() As  Double,
D() As  Double,
Du() As  Double,
Du2() As  Double,
IPiv() As  Long,
Info As  Long 
)

LU factorization of a general tridiagonal matrix

Purpose
This routine computes an LU factorization of a real tridiagonal matrix A using elimination with partial pivoting and row interchanges. The factorization has the form
A = L * U
where L is a product of permutation and unit lower bidiagonal matrices and U is upper triangular with nonzeros in only the main diagonal and first two super-diagonals.
Parameters
[in]NOrder of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in,out]Dl()Array Dl(LDl - 1) (LDl >= N - 1)
[in] N-1 sub-diagonal elements of A.
[out] N-1 multipliers that define the matrix L from the LU factorization of A.
[in,out]D()Array D(LD - 1) (LD >= N)
[in] Diagonal elements of A.
[out] N diagonal elements of the upper triangular matrix U from the LU factorization of A.
[in,out]Du()Array Du(LDu - 1) (LDu >= N - 1)
[in] N-1 super-diagonal elements of A.
[out] N-1 elements of the first super-diagonal of U.
[out]Du2()Array Du2(LDu2 - 1) (LDu2 >= N - 2)
N-2 elements of the second super-diagonal of U.
[out]IPiv()Array IPiv(LIPiv - 1) (LIPiv >= N)
Pivot indices; for 1 <= i <= N, row i of the matrix was interchanged with row IPiv(i-1). IPiv(i-1) will always be either i or i+1; IPiv(i-1) = i indicates a row interchange was not required.
[out]Info= 0: Successful exit.
= -1: The argument N had an illegal value. (N < 0)
= -2: The argument Dl() is invalid.
= -3: The argument D() is invalid.
= -4: The argument Du() is invalid.
= -5: The argument Du2() is invalid.
= -6: 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.58 1.14 0 ) ( -0.5960 )
A = ( -1.56 2.21 0.16 ), B = ( -0.6798 )
( 0 0.24 0.25 ) ( -0.0406 )
Sub Ex_Dgttrf()
Const N = 3
Dim Dl(N - 2) As Double, D(N - 1) As Double, Du(N - 2) As Double
Dim Du2(N - 3) As Double, IPiv(N - 1) As Long
Dim B(N - 1) As Double, ANorm As Double, RCond As Double, Info As Long
Dl(0) = -1.56: Dl(1) = 0.24
D(0) = -0.58: D(1) = 2.21: D(2) = 0.25
Du(0) = 1.14: Du(1) = 0.16
B(0) = -0.596: B(1) = -0.6798: B(2) = -0.0406
ANorm = Dlangt("1", N, Dl(), D(), Du())
Call Dgttrf(N, Dl(), D(), Du(), Du2(), IPiv(), Info)
If Info = 0 Then Call Dgttrs("N", N, Dl(), D(), Du(), Du2(), IPiv(), B(), Info)
If Info = 0 Then Call Dgtcon("1", N, Dl(), D(), Du(), Du2(), IPiv(), ANorm, RCond, Info)
Debug.Print "X =", B(0), B(1), B(2)
Debug.Print "RCond =", RCond
Debug.Print "Info =", Info
End Sub
Function Dlangt(Norm As String, N As Long, Dl() As Double, D() As Double, Du() As Double, Optional Info As Long) As Double
One norm, Frobenius norm, infinity norm, or largest absolute value of any element of a general tridia...
Sub Dgtcon(Norm As String, N As Long, Dl() As Double, D() As Double, Du() As Double, Du2() As Double, IPiv() As Long, ANorm As Double, RCond As Double, Info As Long)
Condition number of a general tridiagonal matrix
Sub Dgttrf(N As Long, Dl() As Double, D() As Double, Du() As Double, Du2() As Double, IPiv() As Long, Info As Long)
LU factorization of a general tridiagonal matrix
Sub Dgttrs(Trans As String, N As Long, Dl() As Double, D() As Double, Du() As Double, Du2() 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 tridiagonal matr...
Example Results
X = -0.82 -0.94 0.74
RCond = 5.28453905459942E-02
Info = 0