# ?gtsv

Computes the solution to the system of linear equations with a tridiagonal matrix A and multiple right-hand sides.

## Syntax

FORTRAN 77:

call sgtsv( n, nrhs, dl, d, du, b, ldb, info )

call dgtsv( n, nrhs, dl, d, du, b, ldb, info )

call cgtsv( n, nrhs, dl, d, du, b, ldb, info )

call zgtsv( n, nrhs, dl, d, du, b, ldb, info )

Fortran 95:

call gtsv( dl, d, du, b [,info] )

## Description

This routine solves for X the system of linear equations `A*X = B`, where A is an n-by-n tridiagonal matrix, the columns of matrix B are individual right-hand sides, and the columns of X are the corresponding solutions. The routine uses Gaussian elimination with partial pivoting.

Note that the equation AT*X = B may be solved by interchanging the order of the arguments du and dl.

## Input Parameters

n

  INTEGER. The order of A, the number of rows in B; n ≥ 0.

nrhs

  INTEGER. The number of right-hand sides, the number of columns in `B; nrhs ≥ 0`.

dl, d, du, b

  REAL for sgtsv

  DOUBLE PRECISION for dgtsv

  COMPLEX for cgtsv

  DOUBLE COMPLEX for zgtsv.

  Arrays: `dl(n - 1), d(n), du(n - 1), b(ldb,*)`.

  The array dl contains the `(n - 1)` subdiagonal elements of A.

  The array d contains the diagonal elements of A.

  The array du contains the `(n - 1)` superdiagonal elements of A.

  The array b contains the matrix B whose columns are the right-hand sides for the systems of equations. The second dimension of b must be at least `max(1,nrhs)`.

ldb

  INTEGER. The first dimension of b; `ldb ≥ max(1, n)`.

## Output Parameters

dl

  Overwritten by the `(n-2)` elements of the second superdiagonal of the upper triangular matrix U from the LU factorization of A. These elements are stored in `dl(1), ... , dl(n-2)`.

d

  Overwritten by the n diagonal elements of U.

du

  Overwritten by the `(n-1)` elements of the first superdiagonal of U.

b

  Overwritten by the solution matrix X.

info

  INTEGER. If `info = 0`, the execution is successful.

  If `info = -i`, the i-th parameter had an illegal value.

  If `info = i`, U(i, i) is exactly zero, and the solution has not been computed. The factorization has not been completed unless `i = n`.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their Fortran 77 counterparts. For general conventions applied to skip redundant or reconstructible arguments, see Fortran 95 Interface Conventions.

Specific details for the routine gtsv interface are as follows:

dl

  Holds the vector of length (`n-1`).

d

  Holds the vector of length (n).

dl

  Holds the vector of length (`n-1`).

b

  Holds the matrix B of size (`n,nrhs`).

Parent topic: Driver Routines