F11MHF (PDF version)
F11 Chapter Contents
F11 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF11MHF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F11MHF returns error bounds for the solution of a real sparse system of linear equations with multiple right-hand sides, $AX=B$ or ${A}^{\mathrm{T}}X=B$. It improves the solution by iterative refinement in standard precision, in order to reduce the backward error as much as possible.

## 2  Specification

 SUBROUTINE F11MHF ( TRANS, N, ICOLZP, IROWIX, A, IPRM, IL, LVAL, IU, UVAL, NRHS, B, LDB, X, LDX, FERR, BERR, IFAIL)
 INTEGER N, ICOLZP(*), IROWIX(*), IPRM(7*N), IL(*), IU(*), NRHS, LDB, LDX, IFAIL REAL (KIND=nag_wp) A(*), LVAL(*), UVAL(*), B(LDB,*), X(LDX,*), FERR(NRHS), BERR(NRHS) CHARACTER(1) TRANS

## 3  Description

F11MHF returns the backward errors and estimated bounds on the forward errors for the solution of a real system of linear equations with multiple right-hand sides $AX=B$ or ${A}^{\mathrm{T}}X=B$. The routine handles each right-hand side vector (stored as a column of the matrix $B$) independently, so we describe the function of F11MHF in terms of a single right-hand side $b$ and solution $x$.
Given a computed solution $x$, the routine computes the component-wise backward error $\beta$. This is the size of the smallest relative perturbation in each element of $A$ and $b$ such that if $x$ is the exact solution of a perturbed system:
 $A+δA x = b + δ b then δaij ≤ β aij and δbi ≤ β bi .$
Then the routine estimates a bound for the component-wise forward error in the computed solution, defined by:
 $maxi xi - x^i / maxi xi$
where $\stackrel{^}{x}$ is the true solution.
The routine uses the $LU$ factorization ${P}_{r}A{P}_{c}=LU$ computed by F11MEF and the solution computed by F11MFF.

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Parameters

1:     TRANS – CHARACTER(1)Input
On entry: specifies whether $AX=B$ or ${A}^{\mathrm{T}}X=B$ is solved.
${\mathbf{TRANS}}=\text{'N'}$
$AX=B$ is solved.
${\mathbf{TRANS}}=\text{'T'}$
${A}^{\mathrm{T}}X=B$ is solved.
Constraint: ${\mathbf{TRANS}}=\text{'N'}$ or $\text{'T'}$.
2:     N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 0$.
3:     ICOLZP($*$) – INTEGER arrayInput
Note: the dimension of the array ICOLZP must be at least ${\mathbf{N}}+1$.
On entry: ${\mathbf{ICOLZP}}\left(i\right)$ contains the index in $A$ of the start of a new column. See Section 2.1.3 in the F11 Chapter Introduction.
4:     IROWIX($*$) – INTEGER arrayInput
Note: the dimension of the array IROWIX must be at least ${\mathbf{ICOLZP}}\left({\mathbf{N}}+1\right)-1$, the number of nonzeros of the sparse matrix $A$.
On entry: the row index array of sparse matrix $A$.
5:     A($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array A must be at least ${\mathbf{ICOLZP}}\left({\mathbf{N}}+1\right)-1$, the number of nonzeros of the sparse matrix $A$.
On entry: the array of nonzero values in the sparse matrix $A$.
6:     IPRM($7×{\mathbf{N}}$) – INTEGER arrayInput
On entry: the column permutation which defines ${P}_{c}$, the row permutation which defines ${P}_{r}$, plus associated data structures as computed by F11MEF.
7:     IL($*$) – INTEGER arrayInput
Note: the dimension of the array IL must be at least as large as the dimension of the array of the same name in F11MEF.
On entry: records the sparsity pattern of matrix $L$ as computed by F11MEF.
8:     LVAL($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array LVAL must be at least as large as the dimension of the array of the same name in F11MEF.
On entry: records the nonzero values of matrix $L$ and some nonzero values of matrix $U$ as computed by F11MEF.
9:     IU($*$) – INTEGER arrayInput
Note: the dimension of the array IU must be at least as large as the dimension of the array of the same name in F11MEF.
On entry: records the sparsity pattern of matrix $U$ as computed by F11MEF.
10:   UVAL($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array UVAL must be at least as large as the dimension of the array of the same name in F11MEF.
On entry: records some nonzero values of matrix $U$ as computed by F11MEF.
11:   NRHS – INTEGERInput
On entry: $\mathit{nrhs}$, the number of right-hand sides in $B$.
Constraint: ${\mathbf{NRHS}}\ge 0$.
12:   B(LDB,$*$) – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array B must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{NRHS}}\right)$.
On entry: the $n$ by $\mathit{nrhs}$ right-hand side matrix $B$.
13:   LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F11MHF is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
14:   X(LDX,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array X must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{NRHS}}\right)$.
On entry: the $n$ by $\mathit{nrhs}$ solution matrix $X$, as returned by F11MFF.
On exit: the $n$ by $\mathit{nrhs}$ improved solution matrix $X$.
15:   LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which F11MHF is called.
Constraint: ${\mathbf{LDX}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
16:   FERR(NRHS) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{FERR}}\left(\mathit{j}\right)$ contains an estimated error bound for the $\mathit{j}$th solution vector, that is, the $\mathit{j}$th column of $X$, for $\mathit{j}=1,2,\dots ,\mathit{nrhs}$.
17:   BERR(NRHS) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{BERR}}\left(\mathit{j}\right)$ contains the component-wise backward error bound $\beta$ for the $\mathit{j}$th solution vector, that is, the $\mathit{j}$th column of $X$, for $\mathit{j}=1,2,\dots ,\mathit{nrhs}$.
18:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{TRANS}}\ne \text{'N'}$ or $\text{'T'}$, or ${\mathbf{N}}<0$, or ${\mathbf{NRHS}}<0$, or ${\mathbf{LDB}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$, or ${\mathbf{LDX}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
${\mathbf{IFAIL}}=2$
Ill-defined row permutation in array ${\mathbf{IPRM}}$. Internal checks have revealed that the ${\mathbf{IPRM}}$ array is corrupted.
${\mathbf{IFAIL}}=3$
Ill-defined column permutations in array ${\mathbf{IPRM}}$. Internal checks have revealed that the ${\mathbf{IPRM}}$ array is corrupted.
${\mathbf{IFAIL}}=301$
Unable to allocate required internal workspace.

## 7  Accuracy

The bounds returned in FERR are not rigorous, because they are estimated, not computed exactly; but in practice they almost always overestimate the actual error.

## 8  Further Comments

At most five steps of iterative refinement are performed, but usually only one or two steps are required.
Estimating the forward error involves solving a number of systems of linear equations of the form $Ax=b$ or ${A}^{\mathrm{T}}x=b$;

## 9  Example

This example solves the system of equations $AX=B$ using iterative refinement and to compute the forward and backward error bounds, where
 $A= 2.00 1.00 0 0 0 0 0 1.00 -1.00 0 4.00 0 1.00 0 1.00 0 0 0 1.00 2.00 0 -2.00 0 0 3.00 and B= 1.56 3.12 -0.25 -0.50 3.60 7.20 1.33 2.66 0.52 1.04 .$
Here $A$ is nonsymmetric and must first be factorized by F11MEF.

### 9.1  Program Text

Program Text (f11mhfe.f90)

### 9.2  Program Data

Program Data (f11mhfe.d)

### 9.3  Program Results

Program Results (f11mhfe.r)

F11MHF (PDF version)
F11 Chapter Contents
F11 Chapter Introduction
NAG Library Manual