# ?gtsvx

Computes the solution to the real or complex system of linear equations with a tridiagonal matrix A and multiple right-hand sides, and provides error bounds on the solution.

## Syntax

FORTRAN 77:

call sgtsvx( fact, trans, n, nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, ldb, x, ldx, rcond, ferr, berr, work, iwork, info )

call dgtsvx( fact, trans, n, nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, ldb, x, ldx, rcond, ferr, berr, work, iwork, info )

call cgtsvx( fact, trans, n, nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, ldb, x, ldx, rcond, ferr, berr, work, rwork, info )

call zgtsvx( fact, trans, n, nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, ldb, x, ldx, rcond, ferr, berr, work, rwork, info )

Fortran 95:

call gtsvx( dl, d, du, b, x [,dlf] [,df] [,duf] [,du2] [,ipiv] [,fact] [,trans] [,ferr] [,berr] [,rcond] [,info] )

## Description

This routine uses the LU factorization to compute the solution to a real or complex system of linear equations `A*X = B`, AT*X = B, or AH*X = B, where A is a tridiagonal matrix of order n, the columns of matrix B are individual right-hand sides, and the columns of X are the corresponding solutions.

Error bounds on the solution and a condition estimate are also provided.

The routine ?gtsvx performs the following steps:

1. If `fact = 'N'`, the LU decomposition is used to factor the matrix A as `A = L*U`, where L is a product of permutation and unit lower bidiagonal matrices and U is an upper triangular matrix with nonzeroes in only the main diagonal and first two superdiagonals.

2. If some `Ui,i` = 0, so that U is exactly singular, then the routine returns with `info = i`. Otherwise, the factored form of A is used to estimate the condition number of the matrix A. If the reciprocal of the condition number is less than machine precision, `info = n + 1` is returned as a warning, but the routine still goes on to solve for X and compute error bounds as described below.

3. The system of equations is solved for X using the factored form of A.

4. Iterative refinement is applied to improve the computed solution matrix and calculate error bounds and backward error estimates for it.

## Input Parameters

fact

  CHARACTER*1. Must be 'F' or 'N'.

  Specifies whether or not the factored form of the matrix A has been supplied on entry.

  If `fact = 'F'`: on entry, dlf, df, duf, du2, and ipiv contain the factored form of A; arrays dl, d, du, dlf, df, duf, du2, and ipiv will not be modified.

  If `fact = 'N'`, the matrix A will be copied to dlf, df, and duf and factored.

trans

  CHARACTER*1. Must be 'N', 'T', or 'C'.

  Specifies the form of the system of equations:

  If `trans = 'N'`, the system has the form `A*X = B` (No transpose).

  If `trans = 'T'`, the system has the form AT*X = B (Transpose).

  If `trans = 'C'`, the system has the form AH*X = B (Conjugate transpose).

n

  INTEGER. The number of linear equations, the order of the matrix A; n ≥ 0.

nrhs

  INTEGER. The number of right hand sides, the number of columns of the matrices B and X; nrhs ≥ 0.

dl,d,du,dlf,df, duf,du2,b,
x,work

  REAL for sgtsvx

  DOUBLE PRECISION for dgtsvx

  COMPLEX for cgtsvx

  DOUBLE COMPLEX for zgtsvx.

  Arrays:

  dl, dimension (n -1), contains the subdiagonal elements of A.

  d, dimension (n), contains the diagonal elements of A.

  du, dimension (n -1), contains the superdiagonal elements of A.

  dlf, dimension (n -1). If `fact = 'F'` , then dlf is an input argument and on entry contains the (n -1) multipliers that define the matrix L from the LU factorization of A as computed by ?gttrf.

  df, dimension (n). If `fact = 'F'` , then df is an input argument and on entry contains the n diagonal elements of the upper triangular matrix U from the LU factorization of A.

  duf, dimension (n -1). If `fact = 'F'` , then duf is an input argument and on entry contains the (n -1) elements of the first superdiagonal of U.

  du2, dimension (n -2). If `fact = 'F'` , then du2 is an input argument and on entry contains the (n-2) elements of the second superdiagonal of U.

  `b(ldb*)` contains the right-hand side matrix B. The second dimension of b must be at least `max(1, nrhs)`.

  `x(ldx*)` contains the solution matrix X. The second dimension of x must be at least `max(1, nrhs)`.

  `work(*)` is a workspace array;

  the dimension of work must be at least `max(1, 3*n)` for real flavors and `max(1, 2*n)` for complex flavors.

ldb

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

ldx

  INTEGER. The first dimension of x; `ldx ≥ max(1, n)`.

ipiv

  INTEGER.

  Array, DIMENSION at least `max(1, n)`. If `fact = 'F'` , then ipiv is an input argument and on entry contains the pivot indices, as returned by ?gttrf.

iwork

  INTEGER. Workspace array, DIMENSION (n). Used for real flavors only.

rwork

  REAL for cgtsvx

  DOUBLE PRECISION for zgtsvx.

  Workspace array, DIMENSION (n). Used for complex flavors only.

## Output Parameters

x

  REAL for sgtsvx

  DOUBLE PRECISION for dgtsvx

  COMPLEX for cgtsvx

  DOUBLE COMPLEX for zgtsvx.

  Array, DIMENSION `(ldx,*)`.

  If `info = 0` or `info = n+1`, the array x contains the solution matrix X. The second dimension of x must be at least `max(1, nrhs)`.

dlf

  If `fact = 'N'` , then dlf is an output argument and on exit contains the `(n-1)` multipliers that define the matrix L from the LU factorization of A.

df

  If `fact = 'N'` , then df is an output argument and on exit contains the n diagonal elements of the upper triangular matrix U from the LU factorization of A.

duf

  If `fact = 'N'` , then duf is an output argument and on exit contains the `(n-1)` elements of the first superdiagonal of U.

du2

  If `fact = 'N'` , then du2 is an output argument and on exit contains the `(n-2)` elements of the second superdiagonal of U.

ipiv

  The array ipiv is an output argument if `fact = 'N'` and, on exit, contains the pivot indices from the factorization `A = L*U` ; row i of the matrix was interchanged with row ipiv(i). The value of ipiv(i) will always be i or i+1; ipiv(i)=i indicates a row interchange was not required.

rcond

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  An estimate of the reciprocal condition number of the matrix A. If rcond is less than the machine precision (in particular, if rcond =0), the matrix is singular to working precision. This condition is indicated by a return code of info>0.

ferr

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  Array, DIMENSION at least `max(1, nrhs)`. Contains the estimated forward error bound for each solution vector `x(j)` (the j-th column of the solution matrix X). If xtrue is the true solution corresponding to `x(j)`, `ferr(j)` is an estimated upper bound for the magnitude of the largest element in `(x(j) - xtrue)` divided by the magnitude of the largest element in `x(j)`. The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.

berr

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  Array, DIMENSION at least `max(1, nrhs)`. Contains the component-wise relative backward error for each solution vector `x(j)`, that is, the smallest relative change in any element of A or B that makes `x(j)` an exact solution.

info

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

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

  If `info = i`, and `i ≤ n`, then U(i, i) is exactly zero. The factorization has not been completed unless `i = n`, but the factor U is exactly singular, so the solution and error bounds could not be computed; rcond = 0 is returned. If `info = i`, and `i = n + 1`, then U is nonsingular, but rcond is less than machine precision, meaning that the matrix is singular to working precision. Nevertheless, the solution and error bounds are computed because there are a number of situations where the computed solution can be more accurate than the value of rcond would suggest.

## 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 gtsvx interface are as follows:

dl

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

d

  Holds the vector of length (n).

du

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

b

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

x

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

dlf

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

df

  Holds the vector of length (n).

duf

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

du2

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

ipiv

  Holds the vector of length (n).

ferr

  Holds the vector of length (nrhs).

berr

  Holds the vector of length (nrhs).

fact

  Must be 'N' or 'F'. The default value is 'N'. If `fact = 'F'`, then the arguments dlf, df, duf, du2, and ipiv must be present; otherwise, an error is returned.

trans

  Must be 'N', 'C', or 'T'. The default value is 'N'.

Parent topic: Driver Routines