?gtsv
Solve a system of linear equations A * X = B, where A is a general tridiagonal matrix.
Interface Definition
C interface:
void sgtsv(const int *N, const int *NRHS, float *DL, float *D, float *DU, float *B, const int *LDB, int *INFO);
void dgtsv(const int *N, const int *NRHS, double *DL, double *D, double *DU, double *B, const int *LDB, int *INFO);
void cgtsv(const int *N, const int *NRHS, float _Complex *DL, float _Complex *D, float _Complex *DU, float _Complex *B, const int *LDB, int *INFO);
void zgtsv(const int *N, const int *NRHS, double _Complex *DL, double _Complex *D, double _Complex *DU, double _Complex *B, const int *LDB, int *INFO);
Fortran interface:
SGTSV(N, NRHS, DL, D, DU, B, LDB, INFO);
DGTSV(N, NRHS, DL, D, DU, B, LDB, INFO);
CGTSV(N, NRHS, DL, D, DU, B, LDB, INFO);
ZGTSV(N, NRHS, DL, D, DU, B, LDB, INFO);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
N |
Integer |
Number of dimensions in matrix A, N ≥ 0. |
Input |
NRHS |
Integer |
Number of columns in matrix B, NRHS ≥ 0. |
Input |
DL |
|
As an input value, it represents a sub-diagonal element of tridiagonal matrix A, with a dimension of N-1. As an output value, it represents the second super-diagonal element of U. |
Input, output |
D |
|
As an input value, it represents a diagonal element of tridiagonal matrix A, with a dimension of N. As an output value, it represents a diagonal element of matrix U. |
Input, output |
DU |
|
As an input value, it represents a super-diagonal element of tridiagonal matrix A, with a dimension of N-1. As an output value, it represents the first super-diagonal element of U. |
Input, output |
B |
|
Right-hand side matrix, with a dimension of (LDB, NRHS). |
Input, output |
LDB |
Integer |
Leading dimension of matrix B. |
Input |
INFO |
Integer |
|
Output |
Dependency
include "klapack.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | const int n = 4; const int ldb = n; const int nrhs = 1; double dl[] = {0.923077, 0.153846, 0.153846}; double d[] = {0.521739, 0.043478, 0.304348, 0.086957}; double du[] = {0.924528, 0.150943, 0.566038}; double b[] = {0.986301, 0.397260, 0.958904, 0.520548}; int info = 0; dgtsv_(&n, &nrhs, dl, d, du, b, &ldb, &info); if (info != 0) { printf("ERROR, info = %d\n", info); } /* * Output: * d: 0.923077 0.899954 0.318932 -0.186088 * dl: 0.150943 0.000000 0.153846 * du: 0.043478 -0.085316 0.566038 * b: -0.239541 1.201996 3.750506 -0.649209 */ |
Fortran interface:
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) :: b(ldb, nrhs) DATA d / 0.521739, 0.043478, 0.304348, 0.086957 / DATA dl / 0.923077, 0.153846, 0.153846 / DATA du / 0.924528, 0.150943, 0.566038 / DATA b / 0.986301, 0.397260, 0.958904, 0.520548 / EXTERNAL DGTSV CALL DGTSV(n, nrhs, dl, d, du, b, ldb, info); * * Output: * d: 0.923077 0.899954 0.318932 -0.186088 * dl: 0.150943 0.000000 0.153846 * du: 0.043478 -0.085316 0.566038 * b: -0.239541 1.201996 3.750506 -0.649209