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

◆ Ztrtrs()

Sub Ztrtrs ( Uplo As  String,
Trans As  String,
Diag As  String,
N As  Long,
A() As  Complex,
B() As  Complex,
Info As  Long,
Optional Nrhs As  Long = 1 
)

Solution to system of linear equations AX = B, ATX = B or AHX = B for a complex triangular matrix

Purpose
This routine solves a triangular system of the form
A * X = B, A^T * X = B or A^H * X = B
where A is a triangular matrix of order N and B is an N x Nrhs matrix. A check is made to verify that A is nonsingular.
Parameters
[in]Uplo= "U": A is upper triangular.
= "L": A is lower triangular.
[in]TransSpecifies the form of the system of equations:
= "N": A * X = B. (no transpose)
= "T": A^T * X = B. (transpose)
= "C": A^H * X = B. (conjugate transpose)
[in]Diag= "N": A is non-unit triangular.
= "U": A is unit triangular. (Diagonal elements of A() are not referenced and are assumed to be 1)
[in]NOrder of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
N x N triangular matrix A. Only the upper or lower triangular part is to be referenced in accordance with Uplo.
[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 Uplo had an illegal value. (Uplo <> "U" nor "L")
= -2: The argument Trans had an illegal value. (Trans <> "N", "T" nor "C")
= -3: The argument Diag had an illegal value. (Diag <> "N" nor "U")
= -4: The argument N had an illegal value. (N < 0)
= -5: The argument A() is invalid.
= -6: The argument B() is invalid.
= -8: The argument Nrhs had an illegal value. (Nrhs < 0)
= i > 0: The i-th diagonal element of A is zero, indicating that the matrix is singular and the solutions have not been computed.
[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.20-0.11i 0 0 )
A = ( -0.93-0.32i 0.81+0.37i 0 )
( -0.80-0.92i -0.29+0.86i 0.64+0.51i )
( 0.2069+0.0399i )
B = ( -0.6633-0.6775i )
( -0.4965-0.6057i )
Sub Ex_Ztrtrs()
Const N = 3
Dim A(N - 1, N - 1) As Complex, B(N - 1) As Complex
Dim RCond As Double, Info As Long
A(0, 0) = Cmplx(0.2, -0.11)
A(1, 0) = Cmplx(-0.93, -0.32): A(1, 1) = Cmplx(0.81, 0.37)
A(2, 0) = Cmplx(-0.8, -0.92): A(2, 1) = Cmplx(-0.29, 0.86): A(2, 2) = Cmplx(0.64, 0.51)
B(0) = Cmplx(0.2069, 0.0399): B(1) = Cmplx(-0.6633, -0.6775): B(2) = Cmplx(-0.4965, -0.6057)
Call Ztrtrs("L", "N", "N", N, A(), B(), Info)
If Info = 0 Then Call Ztrcon("1", "L", "N", N, A(), RCond, 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 "RCond =", RCond
Debug.Print "Info =", Info
End Sub
Example Results
X = 0.71 0.59 -0.15 0.19 0.2 0.94
RCond = 2.79371684875664E-02
Info = 0