Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zgbrfs (f07bv)

## Purpose

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

## Syntax

[x, ferr, berr, info] = f07bv(trans, kl, ku, ab, afb, ipiv, b, x, 'n', n, 'nrhs_p', nrhs_p)
[x, ferr, berr, info] = nag_lapack_zgbrfs(trans, kl, ku, ab, afb, ipiv, b, x, 'n', n, 'nrhs_p', nrhs_p)

## Description

nag_lapack_zgbrfs (f07bv) returns the backward errors and estimated bounds on the forward errors for the solution of a complex band system of linear equations with multiple right-hand sides AX = B$AX=B$, ATX = B${A}^{\mathrm{T}}X=B$ or AHX = B${A}^{\mathrm{H}}X=B$. The function handles each right-hand side vector (stored as a column of the matrix B$B$) independently, so we describe the function of nag_lapack_zgbrfs (f07bv) in terms of a single right-hand side b$b$ and solution x$x$.
Given a computed solution x$x$, the function computes the component-wise backward error β$\beta$. This is the size of the smallest relative perturbation in each element of A$A$ and b$b$ such that x$x$ is the exact solution of a perturbed system
 (A + δA)x = b + δb |δaij| ≤ β|aij|   and   |δbi| ≤ β|bi| .
$(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:
 max |xi − x̂i| / max |xi| i i
$maxi|xi-x^i|/maxi|xi|$
where $\stackrel{^}{x}$ is the true solution.
For details of the method, see the F07 Chapter Introduction.

## References

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

## Parameters

### Compulsory Input Parameters

1:     trans – string (length ≥ 1)
Indicates the form of the linear equations for which X$X$ is the computed solution as follows:
trans = 'N'${\mathbf{trans}}=\text{'N'}$
The linear equations are of the form AX = B$AX=B$.
trans = 'T'${\mathbf{trans}}=\text{'T'}$
The linear equations are of the form ATX = B${A}^{\mathrm{T}}X=B$.
trans = 'C'${\mathbf{trans}}=\text{'C'}$
The linear equations are of the form AHX = B${A}^{\mathrm{H}}X=B$.
Constraint: trans = 'N'${\mathbf{trans}}=\text{'N'}$, 'T'$\text{'T'}$ or 'C'$\text{'C'}$.
2:     kl – int64int32nag_int scalar
kl${k}_{l}$, the number of subdiagonals within the band of the matrix A$A$.
Constraint: kl0${\mathbf{kl}}\ge 0$.
3:     ku – int64int32nag_int scalar
ku${k}_{u}$, the number of superdiagonals within the band of the matrix A$A$.
Constraint: ku0${\mathbf{ku}}\ge 0$.
4:     ab(ldab, : $:$) – complex array
The first dimension of the array ab must be at least kl + ku + 1${\mathbf{kl}}+{\mathbf{ku}}+1$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The original n$n$ by n$n$ band matrix A$A$ as supplied to nag_lapack_zgbtrf (f07br).
The matrix is stored in rows 1$1$ to kl + ku + 1${k}_{l}+{k}_{u}+1$, more precisely, the element Aij${A}_{ij}$ must be stored in
 ab(ku + 1 + i − j,j)  for ​max (1,j − ku) ≤ i ≤ min (n,j + kl).$abku+1+i-jj for ​max(1,j-ku)≤i≤min(n,j+kl).$
See Section [Further Comments] in (f07bn) for further details.
5:     afb(ldafb, : $:$) – complex array
The first dimension of the array afb must be at least 2 × kl + ku + 1$2×{\mathbf{kl}}+{\mathbf{ku}}+1$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The LU$LU$ factorization of A$A$, as returned by nag_lapack_zgbtrf (f07br).
6:     ipiv( : $:$) – int64int32nag_int array
Note: the dimension of the array ipiv must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The pivot indices, as returned by nag_lapack_zgbtrf (f07br).
7:     b(ldb, : $:$) – complex array
The first dimension of the array b must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least max (1,nrhs)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$
The n$n$ by r$r$ right-hand side matrix B$B$.
8:     x(ldx, : $:$) – complex array
The first dimension of the array x must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least max (1,nrhs)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$
The n$n$ by r$r$ solution matrix X$X$, as returned by nag_lapack_zgbtrs (f07bs).

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The second dimension of the array ab.
n$n$, the order of the matrix A$A$.
Constraint: n0${\mathbf{n}}\ge 0$.
2:     nrhs_p – int64int32nag_int scalar
Default: The second dimension of the arrays b, x.
r$r$, the number of right-hand sides.
Constraint: nrhs0${\mathbf{nrhs}}\ge 0$.

### Input Parameters Omitted from the MATLAB Interface

ldab ldafb ldb ldx work rwork

### Output Parameters

1:     x(ldx, : $:$) – complex array
The first dimension of the array x will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array will be max (1,nrhs)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nrhs}}\right)$
ldxmax (1,n)$\mathit{ldx}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The improved solution matrix X$X$.
2:     ferr(nrhs_p) – double array
ferr(j)${\mathbf{ferr}}\left(\mathit{j}\right)$ contains an estimated error bound for the j$\mathit{j}$th solution vector, that is, the j$\mathit{j}$th column of X$X$, for j = 1,2,,r$\mathit{j}=1,2,\dots ,r$.
3:     berr(nrhs_p) – double array
berr(j)${\mathbf{berr}}\left(\mathit{j}\right)$ contains the component-wise backward error bound β$\beta$ for the j$\mathit{j}$th solution vector, that is, the j$\mathit{j}$th column of X$X$, for j = 1,2,,r$\mathit{j}=1,2,\dots ,r$.
4:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: trans, 2: n, 3: kl, 4: ku, 5: nrhs_p, 6: ab, 7: ldab, 8: afb, 9: ldafb, 10: ipiv, 11: b, 12: ldb, 13: x, 14: ldx, 15: ferr, 16: berr, 17: work, 18: rwork, 19: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.

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

For each right-hand side, computation of the backward error involves a minimum of 16n(kl + ku)$16n\left({k}_{l}+{k}_{u}\right)$ real floating point operations. Each step of iterative refinement involves an additional 8n(4kl + 3ku)$8n\left(4{k}_{l}+3{k}_{u}\right)$ real operations. This assumes nkl$n\gg {k}_{l}$ and nku$n\gg {k}_{u}$. 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$Ax=b$ or AHx = b${A}^{\mathrm{H}}x=b$; the number is usually 5$5$ and never more than 11$11$. Each solution involves approximately 8n(2kl + ku)$8n\left(2{k}_{l}+{k}_{u}\right)$ real operations.
The real analogue of this function is nag_lapack_dgbrfs (f07bh).

## Example

```function nag_lapack_zgbrfs_example
trans = 'N';
kl = int64(1);
ku = int64(2);
ab = [0,  0 + 0i,  0.97 - 2.84i,  0.59 - 0.48i;
0 + 0i,  -2.05 - 0.85i,  -3.99 + 4.01i,  3.33 - 1.04i;
-1.65 + 2.26i,  -1.48 - 1.75i,  -1.06 + 1.94i,  -0.46 - 1.72i;
0 + 6.3i,  -0.77 + 2.83i,  4.48 - 1.09i,  0 + 0i];
afb = [0,  0 + 0i,  0 + 0i,  0.59 - 0.48i;
0 + 0i,  0 + 0i,  -3.99 + 4.01i,  3.33 - 1.04i;
0 + 0i,  -1.48 - 1.75i,  -1.06 + 1.94i,  -1.769209381609681 - 1.858747281945787i;
0 + 6.3i,  -0.77 + 2.83i, ...
4.930266941175471 - 3.008563740627192i,  0.4337749265901603 + 0.123252818156083i;
0.3587301587301587 + 0.2619047619047619i, ...
0.2314260728743743 + 0.6357648842047455i,  0.7604226619635511 + 0.2429442589267133i,  0 + 0i];
ipiv = [int64(2);3;3;4];
b = [ -1.06 + 21.5i,  12.85 + 2.84i;
-22.72 - 53.9i,  -70.22 + 21.57i;
28.24 - 38.6i,  -20.73 - 1.23i;
-34.56 + 16.73i,  26.01 + 31.97i];
x = [ -3 + 2i,  1 + 6i;
1 - 7i,  -7 - 4i;
-5 + 4i,  3 + 5i;
6 - 8i,  -8 + 2i];
[xOut, ferr, berr, info] = nag_lapack_zgbrfs(trans, kl, ku, ab, afb, ipiv, b, x)
```
```

xOut =

-3.0000 + 2.0000i   1.0000 + 6.0000i
1.0000 - 7.0000i  -7.0000 - 4.0000i
-5.0000 + 4.0000i   3.0000 + 5.0000i
6.0000 - 8.0000i  -8.0000 + 2.0000i

ferr =

1.0e-13 *

0.3492
0.4309

berr =

1.0e-16 *

0.2899
0.5497

info =

0

```
```function f07bv_example
trans = 'N';
kl = int64(1);
ku = int64(2);
ab = [0,  0 + 0i,  0.97 - 2.84i,  0.59 - 0.48i;
0 + 0i,  -2.05 - 0.85i,  -3.99 + 4.01i,  3.33 - 1.04i;
-1.65 + 2.26i,  -1.48 - 1.75i,  -1.06 + 1.94i,  -0.46 - 1.72i;
0 + 6.3i,  -0.77 + 2.83i,  4.48 - 1.09i,  0 + 0i];
afb = [0,  0 + 0i,  0 + 0i,  0.59 - 0.48i;
0 + 0i,  0 + 0i,  -3.99 + 4.01i,  3.33 - 1.04i;
0 + 0i,  -1.48 - 1.75i,  -1.06 + 1.94i,  -1.769209381609681 - 1.858747281945787i;
0 + 6.3i,  -0.77 + 2.83i, ...
4.930266941175471 - 3.008563740627192i,  0.4337749265901603 + 0.123252818156083i;
0.3587301587301587 + 0.2619047619047619i, ...
0.2314260728743743 + 0.6357648842047455i,  0.7604226619635511 + 0.2429442589267133i,  0 + 0i];
ipiv = [int64(2);3;3;4];
b = [ -1.06 + 21.5i,  12.85 + 2.84i;
-22.72 - 53.9i,  -70.22 + 21.57i;
28.24 - 38.6i,  -20.73 - 1.23i;
-34.56 + 16.73i,  26.01 + 31.97i];
x = [ -3 + 2i,  1 + 6i;
1 - 7i,  -7 - 4i;
-5 + 4i,  3 + 5i;
6 - 8i,  -8 + 2i];
[xOut, ferr, berr, info] = f07bv(trans, kl, ku, ab, afb, ipiv, b, x)
```
```

xOut =

-3.0000 + 2.0000i   1.0000 + 6.0000i
1.0000 - 7.0000i  -7.0000 - 4.0000i
-5.0000 + 4.0000i   3.0000 + 5.0000i
6.0000 - 8.0000i  -8.0000 + 2.0000i

ferr =

1.0e-13 *

0.3492
0.4309

berr =

1.0e-16 *

0.2899
0.5497

info =

0

```

Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013