?gttrs
Solve a system of linear equations with a tridiagonal matrix A * X = B, AT * X = B, or AH * X = B, where coefficient matrix A is the ?gttrf factorization result.
Interface Definition
C interface:
void sgttrs(const char *TRANS, const int *N, const int *NRHS, float *DL, float *D, float *DU, float *DU2, int *IPIV, float *B, const int *LDB, int *INFO);
void dgttrs(const char *TRANS, const int *N, const int *NRHS, double *DL, double *D, double *DU, double *DU2, int *IPIV, double *B, const int *LDB, int *INFO);
void cgttrs(const char *TRANS, const int *N, const int *NRHS, float _Complex *DL, float _Complex *D, float _Complex *DU, float _Complex *DU2, int *IPIV, float _Complex *B, const int *LDB, int *INFO);
void zgttrs(const char *TRANS, const int *N, const int *NRHS, double _Complex *DL, double _Complex *D, double _Complex *DU, double _Complex *DU2, int *IPIV, double _Complex *B, const int *LDB, int *INFO);
Fortran interface:
SGTTRS(TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB, INFO);
DGTTRS(TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB, INFO);
CGTTRS(TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB, INFO);
ZGTTRS(TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB, INFO);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
TRANS |
Character |
|
Input |
N |
Integer |
Order of matrix A, N ≥ 0 |
Input |
NRHS |
Integer |
Number of columns in matrix B, NRHS ≥ 0 |
Input |
DL |
|
Matrix L from the LU decomposition, with a dimension of N–1 |
Input |
D |
|
Diagonal element of U, with a dimension of N |
Input |
DU |
|
First super-diagonal element of U |
Input |
DU2 |
|
Second super-diagonal element of U |
Input |
IPIV |
Integer array |
Transposed array |
Input |
B |
|
Right-hand side matrix, with a dimension of (LDB, NRHS) |
Input/Output |
LDB |
Integer |
Leading dimension of matrix B |
Input |
INFO |
Integer |
0: The exit is successful. Smaller than 0: The -INFO-th parameter is invalid. |
Output |
Dependencies
include "klapack.h"
Examples
C interface:
const char trans = 'N';
const int n = 4;
const int ldb = n;
const int nrhs = 1;
double dl[] = {0.565217, 0.170949, 0.482378};
double d[] = {0.923077, 0.899954, 0.318932, -0.186088};
double du[] = {0.043478, -0.085316, 0.566038};
double du2[] = {0.150943, 0.000000};
double b[] = {0.301370, 0.835616, 0.109589, 0.041096};
int ipiv[] = {2,2,3,4};
int info = 0;
dgttrs_(&trans, &n, &nrhs, dl, d, du, du2, ipiv, b, &ldb, &info);
if (info != 0) {
printf("ERROR, info = %d\n", info);
}
/*
* Output:
* b: 0.882521 -0.172061 0.188567 0.138984
*/
Fortran interface:
CHARACTER :: trans = "N" PARAMETER (n = 4) PARAMETER (ldb = 4) PARAMETER (nrhs = 1) INTEGER :: info = 0 REAL(8) :: d(n) REAL(8) :: dl(n-1) REAL(8) :: du(n-1) REAL(8) :: du2(n-2) REAL(8) :: b(ldb, nrhs) INTEGER :: ipiv(n) DATA d / 0.923077, 0.899954, 0.318932, -0.186088 / DATA dl / 0.565217, 0.170949, 0.482378/ DATA du / 0.043478, -0.085316, 0.566038 / DATA du2 / 0.150943, 0.000000 / DATA b / 0.301370, 0.835616, 0.109589, 0.041096 / DATA ipiv / 2,2,3,4 / EXTERNAL DGTTRS CALL DGTTRS(trans, n, nrhs, dl, d, du, du2, ipiv, b, ldb, info); * * Output: * d: 0.882521 -0.172061 0.188567 0.138984