# p?gerfs

Improves the computed solution to a system of linear equations and provides error bounds and backward error estimates for the solution.

## Syntax

call psgerfs(trans, n, nrhs, a, ia, ja, desca, af, iaf, jaf, descaf, ipiv, b, ib, jb, descb, x, ix, jx, descx, ferr, berr, work, lwork, iwork, liwork, info)

call pdgerfs(trans, n, nrhs, a, ia, ja, desca, af, iaf, jaf, descaf, ipiv, b, ib, jb, descb, x, ix, jx, descx, ferr, berr, work, lwork, iwork, liwork, info)

call pcgerfs(trans, n, nrhs, a, ia, ja, desca, af, iaf, jaf, descaf, ipiv, b, ib, jb, descb, x, ix, jx, descx, ferr, berr, work, lwork, rwork, lrwork, info)

call pzgerfs(trans, n, nrhs, a, ia, ja, desca, af, iaf, jaf, descaf, ipiv, b, ib, jb, descb, x, ix, jx, descx, ferr, berr, work, lwork, rwork, lrwork, info)

## Description

This routine improves the computed solution to one of the systems of linear equations

`sub(A)*sub(X) = sub(B),`

`sub(A)T*sub(X) = sub(B)`, or

`sub(A)H*sub(X) = sub(B)` and provides error bounds and backward error estimates for the solution.

Here `sub(A) = A(ia:ia+n-1, ja:ja+n-1)`, `sub(B) = B(ib:ib+n-1, jb:jb+nrhs-1)`, and `sub(X) = X(ix:ix+n-1, jx:jx+nrhs-1)`.

## Input Parameters

trans

  (global) CHARACTER*1. Must be 'N' or 'T' or 'C'.

  Specifies the form of the system of equations:

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

  If `trans = 'T'`, the system has the form `sub(A)T*sub(X) = sub(B)` (Transpose);

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

n

  (global) INTEGER. The order of the distributed submatrix sub(A) `(n ≥ 0)`.

nrhs

  (global) INTEGER. The number of right-hand sides, i.e., the number of columns of the matrices sub(B) and sub(X) `(nrhs ≥ 0)`.

a, af, b, x

  (local)

  REAL for psgerfs

  DOUBLE PRECISION for pdgerfs

  COMPLEX for pcgerfs

  DOUBLE COMPLEX for pzgerfs.

  Pointers into the local memory to arrays of local dimension `a(lld_a`,

  `LOCc(ja+n-1))`, `af(lld_af,LOCc(jaf+n-1)), b(lld_b,``LOCc(jb+nrhs-1))`, and `x(lld_x,LOCc(jx+nrhs-1))`, respectively.

  The array a contains the local pieces of the distributed matrix sub(A).

  The array af contains the local pieces of the distributed factors of the matrix `sub(A) = P*L*U` as computed by p?getrf.

  The array b contains the local pieces of the distributed matrix of right hand sides sub(B).

  On entry, the array x contains the local pieces of the distributed solution matrix sub(X).

ia, ja

  (global) INTEGER. The row and column indices in the global array A indicating the first row and the first column of the submatrix sub(A), respectively.

desca

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix A.

iaf, jaf

  (global) INTEGER. The row and column indices in the global array AF indicating the first row and the first column of the submatrix sub(AF), respectively.

descaf

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix AF.

ib, jb

  (global) INTEGER. The row and column indices in the global array B indicating the first row and the first column of the submatrix sub(B), respectively.

descb

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix B.

ix, jx

  (global) INTEGER. The row and column indices in the global array X indicating the first row and the first column of the submatrix sub(X), respectively.

descx

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix X.

ipiv

  (local) INTEGER.

  Array, dimension `LOCr(m_af + mb_af`.

  This array contains pivoting information as computed by p?getrf. If `ipiv(i)=j`, then the local row i was swapped with the global row j.

  This array is tied to the distributed matrix A.

work

  (local)

  REAL for psgerfs

  DOUBLE PRECISION for pdgerfs

  COMPLEX for pcgerfs

  DOUBLE COMPLEX for pzgerfs.

  The array work of dimension (lwork) is a workspace array.

lwork

  (local or global) INTEGER. The dimension of the array work.

  For real flavors:

  lwork must be at least

  `lwork ≥ 3*LOCr(n+mod(ia-1,mb_a))`

  For complex flavors:

  lwork must be at least

  `lwork ≥ 2*LOCr(n+mod(ia-1,mb_a))`

iwork

  (local) INTEGER. Workspace array, DIMENSION (liwork). Used in real flavors only.

liwork

  (local or global) INTEGER. The dimension of the array iwork; used in real flavors only. Must be at least

  `liwork ≥ LOCr(n+mod(ib-1,mb_b))`.

rwork

  (local) REAL for pcgerfs

  DOUBLE PRECISION for pzgerfs

  Workspace array, DIMENSION (lrwork). Used in complex flavors only.

lrwork

  (local or global) INTEGER. The dimension of the array rwork; used in complex flavors only. Must be at least `lrwork ≥ LOCr(n+mod(ib-1,mb_b)))`.

## Output Parameters

x

  On exit, contains the improved solution vectors.

ferr, berr

  REAL for single precision flavors.

  DOUBLE PRECISION for double precision flavors.

  Arrays, dimension `LOCc(jb+nrhs-1)` each.

  The array ferr contains the estimated forward error bound for each solution vector of sub(X).

  If XTRUE is the true solution corresponding to sub(X), ferr is an estimated upper bound for the magnitude of the largest element in `(sub(X) - XTRUE)` divided by the magnitude of the largest element in sub(X). The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.

  This array is tied to the distributed matrix X.

  The array berr contains the component-wise relative backward error of each solution vector (that is, the smallest relative change in any entry of sub(A) or sub(B) that makes sub(X) an exact solution). This array is tied to the distributed matrix X.

`work(1)`

  On exit, `work(1)` contains the minimum value of lwork required for optimum performance.

`iwork(1)`

  On exit, `iwork(1)` contains the minimum value of liwork required for optimum performance (for real flavors).

`rwork(1)`

  On exit, `rwork(1)` contains the minimum value of lrwork required for optimum performance (for complex flavors).

info

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

  `info < 0`:

  If the ith argument is an array and the jth entry had an illegal value, then `info = -(i*100+j)`; if the i-th argument is a scalar and had an illegal value, then `info = -i`.

Parent topic: Refining the Solution and Estimating Its Error