|
|
◆ Dtrtrs()
| Sub Dtrtrs |
( |
Uplo As |
String, |
|
|
Trans As |
String, |
|
|
Diag As |
String, |
|
|
N As |
Long, |
|
|
A() 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
- Purpose
- This routine solves a triangular system of the form 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] | Trans | Specifies 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 A() are not referenced and are assumed to be 1) |
| [in] | N | Order 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
( -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_Dtrtrs()
Const N = 3
Dim A(N - 1, N - 1) As Double, B(N - 1) As Double
Dim RCond As Double, Info As Long
A(0, 0) = -1.13
A(1, 0) = 0.26: A(1, 1) = -1.98
A(2, 0) = -0.96: A(2, 1) = 0.3: A(2, 2) = -2.32
B(0) = 0.0452: B(1) = -0.4856: B(2) = 1.2472
Call Dtrtrs("L", "N", "N", N, A(), B(), Info)
If Info = 0 Then Call Dtrcon("1", "L", "N", N, A(), RCond, Info)
Debug.Print "X =", B(0), B(1), B(2)
Debug.Print "RCond =", RCond
Debug.Print "Info =", Info
End Sub
Sub Dtrtrs(Uplo As String, Trans As String, Diag As String, N As Long, A() 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
Sub Dtrcon(Norm As String, Uplo As String, Diag As String, N As Long, A() As Double, RCond As Double, Info As Long) Condition number of a triangular matrix
- Example Results
X = -0.04 0.24 -0.49
RCond = 0.314667138698574
Info = 0
|