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

◆ Dtptrs()

Sub Dtptrs ( Uplo As  String,
Trans As  String,
Diag As  String,
N As  Long,
Ap() As  Double,
B() As  Double,
Info As  Long,
Optional Nrhs As  Long = 1 
)

Solution to system of linear equations AX = B or ATX = B for a triangular matrix in packed form

Purpose
This routine solves a triangular system of the form
A * X = B or A^T * X = B
where A is a triangular matrix of order n stored in packed form, 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" or "C": A^T * X = B. (transpose)
[in]Diag= "N": A is non-unit triangular.
= "U": A is unit triangular. (Diagonal elements of Ap() are not referenced and are assumed to be 1)
[in]NOrder of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in]Ap()Array Ap(LAp - 1) (LAp >= N(N + 1)/2)
N x N triangular matrix A in packed symmetric matrix form. Upper or lower part is to be stored 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 Ap() 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 X 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
( -1.13 0 0 ) ( 0.0452 )
A = ( 0.26 -1.98 0 ), B = ( -0.4856 )
( -0.96 0.30 -2.32 ) ( 1.2472 )
Sub Ex_Dtptrs()
Const N = 3
Dim Ap(N * (N + 1) / 2) As Double, B(N - 1) As Double
Dim RCond As Double, Info As Long
Ap(0) = -1.13
Ap(1) = 0.26: Ap(3) = -1.98
Ap(2) = -0.96: Ap(4) = 0.3: Ap(5) = -2.32
B(0) = 0.0452: B(1) = -0.4856: B(2) = 1.2472
Call Dtptrs("L", "N", "N", N, Ap(), B(), Info)
If Info = 0 Then Call Dtpcon("1", "L", "N", N, Ap(), RCond, Info)
Debug.Print "X =", B(0), B(1), B(2)
Debug.Print "RCond =", RCond
Debug.Print "Info =", Info
End Sub
Sub Dtptrs(Uplo As String, Trans As String, Diag As String, N As Long, Ap() As Double, B() As Double, Info As Long, Optional Nrhs As Long=1)
Solution to system of linear equations AX = B or ATX = B for a triangular matrix in packed form
Sub Dtpcon(Norm As String, Uplo As String, Diag As String, N As Long, Ap() As Double, RCond As Double, Info As Long)
Condition number of a triangular matrix in packed form
Example Results
X = -0.04 0.24 -0.49
RCond = 0.314667138698574
Info = 0