Rate This Document
Findability
Accuracy
Completeness
Readability

?gtsv

Solve the system of linear equations A * X = B, where A is a general tridiagonal coefficient 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

  • A single-precision floating-point array for sgtsv
  • A double-precision floating-point array for dgtsv
  • A single-precision complex array for cgtsv
  • A double-precision complex array for zgtsv

When as an input value, it is a sub-diagonal element of tridiagonal matrix A, and its dimension is N-1.

When as an output value, it is the second super-diagonal element of U.

Input, output

D

  • A single-precision floating-point array for sgtsv
  • A double-precision floating-point array for dgtsv
  • A single-precision complex array for cgtsv
  • A double-precision complex array for zgtsv

When as an input value, it is a diagonal element of tridiagonal matrix A, and its dimension is N.

When as an output value, it is a diagonal element of U.

Input, output

DU

  • A single-precision floating-point array for sgtsv
  • A double-precision floating-point array for dgtsv
  • A single-precision complex array for cgtsv
  • A double-precision complex array for zgtsv

When as an input value, it is a super-diagonal element of tridiagonal matrix A, and its dimension is N-1.

When as an output value, it is the first super-diagonal element of U.

Input, output

B

  • A single-precision floating-point array for sgtsv
  • A double-precision floating-point array for dgtsv
  • A single-precision complex array for cgtsv
  • A double-precision complex array for zgtsv

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 value of the -info-th parameter is invalid.
  • Greater than 0: U(INFO, INFO) is 0.

Output

Dependency

include "klapack.h"

Examples

C interface:

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