# ?gtrfs

Refines the solution of a system of linear equations with a tridiagonal matrix and estimates its error.

## Syntax

FORTRAN 77:

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

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

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

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

Fortran 95:

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

## Description

This routine performs an iterative refinement of the solution to a system of linear equations `A*X = B` or `AT*X = B` or AH*X = B with a tridiagonal matrix A, with multiple right-hand sides. For each computed solution vector x, the routine computes the component-wise backward error β. This error is the smallest relative perturbation in elements of A and b such that x is the exact solution of the perturbed system:

`|δaij|/|aij| ≤ β|aij|, |δbi|/|bi| ≤ β|bi|` such that `(A + δA)x = (b + δb)`.

Finally, the routine estimates the component-wise forward error in the computed solution `||x - xe||∞/||x||∞` (here `xe` is the exact solution).

Before calling this routine:

- call the factorization routine ?gttrf

- call the solver routine ?gttrs.

## Input Parameters

trans

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

  Indicates the form of the equations:

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

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

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

n

  INTEGER. The order of the matrix A; n ≥ 0.

nrhs

  INTEGER. The number of right-hand sides, that is, the number of columns of the matrix B; nrhs ≥ 0.

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

  REAL for sgtrfs

  DOUBLE PRECISION for dgtrfs

  COMPLEX for cgtrfs

  DOUBLE COMPLEX for zgtrfs.

  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), contains the (n - 1) multipliers that define the matrix L from the LU factorization of A as computed by ?gttrf.

  df, dimension (n), contains the n diagonal elements of the upper triangular matrix U from the LU factorization of A.

  duf, dimension (n -1), contains the (n - 1) elements of the first superdiagonal of U.

  du2, dimension (n -2), contains the (n - 2) elements of the second superdiagonal of U.

  `b(ldb,nrhs)` contains the right-hand side matrix B.

  `x(ldx,nrhs)` contains the solution matrix X, as computed by ?gttrs.

  `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)`. The ipiv array, as returned by ?gttrf.

iwork

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

rwork

  REAL for cgtrfs

  DOUBLE PRECISION for zgtrfs.

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

## Output Parameters

x

  The refined solution matrix X.

ferr, berr

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  Arrays, DIMENSION at least `max(1,nrhs)`. Contain the component-wise forward and backward errors, respectively, for each solution vector.

info

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

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

## 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 gtrfs 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).

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).

b

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

x

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

ferr

  Holds the vector of length (nrhs).

berr

  Holds the vector of length (nrhs).

trans

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

Parent topic: Refining the Solution and Estimating Its Error