# NAG CL Interfacef07avc (zgerfs)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void f07avc (Nag_OrderType order, Nag_TransType trans, Integer n, Integer nrhs, const Complex a[], Integer pda, const Complex af[], Integer pdaf, const Integer ipiv[], const Complex b[], Integer pdb, Complex x[], Integer pdx, double ferr[], double berr[], NagError *fail)
The function may be called by the names: f07avc, nag_lapacklin_zgerfs or nag_zgerfs.

## 3Description

f07avc returns the backward errors and estimated bounds on the forward errors for the solution of a complex system of linear equations with multiple right-hand sides $AX=B$, ${A}^{\mathrm{T}}X=B$ or ${A}^{\mathrm{H}}X=B$. The function handles each right-hand side vector (stored as a column of the matrix $B$) independently, so we describe the function of f07avc in terms of a single right-hand side $b$ and solution $x$.
Given a computed solution $x$, the function 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 $x$ is the exact solution of a perturbed system
 $(A+δA)x=b+δb |δaij|≤β|aij| and |δbi|≤β|bi| .$
Then the function 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.
For details of the method, see the F07 Chapter Introduction.

## 4References

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

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{trans}$Nag_TransType Input
On entry: indicates the form of the linear equations for which $X$ is the computed solution as follows:
${\mathbf{trans}}=\mathrm{Nag_NoTrans}$
The linear equations are of the form $AX=B$.
${\mathbf{trans}}=\mathrm{Nag_Trans}$
The linear equations are of the form ${A}^{\mathrm{T}}X=B$.
${\mathbf{trans}}=\mathrm{Nag_ConjTrans}$
The linear equations are of the form ${A}^{\mathrm{H}}X=B$.
Constraint: ${\mathbf{trans}}=\mathrm{Nag_NoTrans}$, $\mathrm{Nag_Trans}$ or $\mathrm{Nag_ConjTrans}$.
3: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4: $\mathbf{nrhs}$Integer Input
On entry: $r$, the number of right-hand sides.
Constraint: ${\mathbf{nrhs}}\ge 0$.
5: $\mathbf{a}\left[\mathit{dim}\right]$const Complex Input
Note: the dimension, dim, of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $A$ is stored in
• ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n×n$ original matrix $A$ as supplied to f07arc.
6: $\mathbf{pda}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
7: $\mathbf{af}\left[\mathit{dim}\right]$const Complex Input
Note: the dimension, dim, of the array af must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdaf}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{af}}\left[\left(j-1\right)×{\mathbf{pdaf}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{af}}\left[\left(i-1\right)×{\mathbf{pdaf}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $LU$ factorization of $A$, as returned by f07arc.
8: $\mathbf{pdaf}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array af.
Constraint: ${\mathbf{pdaf}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
9: $\mathbf{ipiv}\left[\mathit{dim}\right]$const Integer Input
Note: the dimension, dim, of the array ipiv must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the pivot indices, as returned by f07arc.
10: $\mathbf{b}\left[\mathit{dim}\right]$const Complex Input
Note: the dimension, dim, of the array b must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdb}}×{\mathbf{nrhs}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdb}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $B$ is stored in
• ${\mathbf{b}}\left[\left(j-1\right)×{\mathbf{pdb}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n×r$ right-hand side matrix $B$.
11: $\mathbf{pdb}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
12: $\mathbf{x}\left[\mathit{dim}\right]$Complex Input/Output
Note: the dimension, dim, of the array x must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdx}}×{\mathbf{nrhs}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdx}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $X$ is stored in
• ${\mathbf{x}}\left[\left(j-1\right)×{\mathbf{pdx}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{x}}\left[\left(i-1\right)×{\mathbf{pdx}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n×r$ solution matrix $X$, as returned by f07asc.
On exit: the improved solution matrix $X$.
13: $\mathbf{pdx}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
14: $\mathbf{ferr}\left[{\mathbf{nrhs}}\right]$double Output
On exit: ${\mathbf{ferr}}\left[\mathit{j}-1\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 ,r$.
15: $\mathbf{berr}\left[{\mathbf{nrhs}}\right]$double Output
On exit: ${\mathbf{berr}}\left[\mathit{j}-1\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 ,r$.
16: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{nrhs}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nrhs}}\ge 0$.
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}>0$.
On entry, ${\mathbf{pdaf}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdaf}}>0$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}>0$.
On entry, ${\mathbf{pdx}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdx}}>0$.
NE_INT_2
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdaf}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdaf}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nrhs}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
On entry, ${\mathbf{pdx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nrhs}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdx}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

## 7Accuracy

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.

## 8Parallelism and Performance

f07avc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f07avc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

For each right-hand side, computation of the backward error involves a minimum of $16{n}^{2}$ real floating-point operations. Each step of iterative refinement involves an additional $24{n}^{2}$ real operations. 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{H}}x=b$; the number is usually $5$ and never more than $11$. Each solution involves approximately $8{n}^{2}$ real operations.
The real analogue of this function is f07ahc.

## 10Example

This example solves the system of equations $AX=B$ using iterative refinement and to compute the forward and backward error bounds, where
 $A= ( -1.34+2.55i 0.28+3.17i -6.39-2.20i 0.72-0.92i -0.17-1.41i 3.31-0.15i -0.15+1.34i 1.29+1.38i -3.29-2.39i -1.91+4.42i -0.14-1.35i 1.72+1.35i 2.41+0.39i -0.56+1.47i -0.83-0.69i -1.96+0.67i )$
and
 $B= ( 26.26+51.78i 31.32-06.70i 6.43-08.68i 15.86-01.42i -5.75+25.31i -2.15+30.19i 1.16+02.57i -2.56+07.55i ) .$
Here $A$ is nonsymmetric and must first be factorized by f07arc.

### 10.1Program Text

Program Text (f07avce.c)

### 10.2Program Data

Program Data (f07avce.d)

### 10.3Program Results

Program Results (f07avce.r)