XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Zgtsv()

Sub Zgtsv ( N As  Long,
Dl() As  Complex,
D() As  Complex,
Du() As  Complex,
B() As  Complex,
Info As  Long,
Optional Nrhs As  Long = 1 
)

(Simple driver) Solution to system of linear equations AX = B for a complex tridiagonal matrix

Purpose
This routine solves the equation
A * X = B
where A is an N x N tridiagonal matrix, by Gaussian elimination with partial pivoting.
Note that the equation A^T*X = B may be solved by interchanging the order of the arguments du and dl.
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-2 elements of the second super-diagonal of the upper triangular matrix U from the LU factorization of A, in Dl(0), ..., Dl(N-3).
[in,out]D()Array D(LD - 1) (LD >= N)
[in] Diagonal elements of A.
[out] Diagonal elements of U.
[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.
[in,out]B()Array B(LB1 - 1, LB2 - 1) (LB1 >= max(1, N), LB2 >= Nrhs) (2D array) or B(LB - 1) (LB >= max(1, N), Nrhs = 1) (1D array)
[in] N x Nrhs matrix of right hand side matrix B.
[out] If Info = 0, the N x Nrhs solution matrix X.
[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 B() is invalid.
= -7: The argument Nrhs had an illegal value. (Nrhs < 0, or, Nrhs <> 1 and B() is 1D array)
= i > 0: The i-th diagonal element of the factor U is exactly zero, and the solution has not been computed. The factorization has not been completed unless i = n.
[in]Nrhs(Optional)
Number of right hand sides, i.e., number of columns of the matrix B. (Nrhs >= 0) (If Nrhs = 0, returns without computation) (default = 1)
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.81+0.37i -0.20-0.11i 0 )
A = ( 0.64+0.51i -0.80-0.92i -0.93-0.32i )
( 0 0.71+0.59i -0.29+0.86i )
( -0.0484+0.2644i )
B = ( -0.2644-1.0228i )
( -0.5299+1.5025i )
Sub Ex_Zgtsv()
Const N = 3
Dim Dl(N - 2) As Complex, D(N - 1) As Complex, Du(N - 2) As Complex
Dim B(N - 1) As Complex, Info As Long
Dl(0) = Cmplx(0.64, 0.51): Dl(1) = Cmplx(0.71, 0.59)
D(0) = Cmplx(0.81, 0.37): D(1) = Cmplx(-0.8, -0.92): D(2) = Cmplx(-0.29, 0.86)
Du(0) = Cmplx(0.2, -0.11): Du(1) = Cmplx(-0.93, -0.32)
B(0) = Cmplx(-0.0484, 0.2644): B(1) = Cmplx(-0.2644, -1.0228): B(2) = Cmplx(-0.5299, 1.5025)
Call Zgtsv(N, Dl(), D(), Du(), B(), Info)
Debug.Print "X =",
Debug.Print Creal(B(0)), Cimag(B(0)), Creal(B(1)), Cimag(B(1)), Creal(B(2)), Cimag(B(2))
Debug.Print "Info =", Info
End Sub
Example Results
X = -0.15 0.19 0.2 0.94 0.79 -0.13
Info = 0