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_dpbsvx (f07hb)

## Purpose

nag_lapack_dpbsvx (f07hb) uses the Cholesky factorization
 A = UTU   or   A = LLT $A=UTU or A=LLT$
to compute the solution to a real system of linear equations
 AX = B , $AX=B ,$
where A$A$ is an n$n$ by n$n$ symmetric positive definite band matrix of bandwidth (2kd + 1) $\left(2{k}_{d}+1\right)$ and X$X$ and B$B$ are n$n$ by r$r$ matrices. Error bounds on the solution and a condition estimate are also provided.

## Syntax

[ab, afb, equed, s, b, x, rcond, ferr, berr, info] = f07hb(fact, uplo, kd, ab, afb, equed, s, b, 'n', n, 'nrhs_p', nrhs_p)
[ab, afb, equed, s, b, x, rcond, ferr, berr, info] = nag_lapack_dpbsvx(fact, uplo, kd, ab, afb, equed, s, b, 'n', n, 'nrhs_p', nrhs_p)

## Description

nag_lapack_dpbsvx (f07hb) performs the following steps:
1. If fact = 'E'${\mathbf{fact}}=\text{'E'}$, real diagonal scaling factors, DS ${D}_{S}$, are computed to equilibrate the system:
 (DSADS) (DS − 1X) = DS B . $( DS A DS ) ( DS-1 X ) = DS B .$
Whether or not the system will be equilibrated depends on the scaling of the matrix A$A$, but if equilibration is used, A$A$ is overwritten by DS A DS ${D}_{S}A{D}_{S}$ and B$B$ by DS B${D}_{S}B$.
2. If fact = 'N'${\mathbf{fact}}=\text{'N'}$ or 'E'$\text{'E'}$, the Cholesky decomposition is used to factor the matrix A$A$ (after equilibration if fact = 'E'${\mathbf{fact}}=\text{'E'}$) as A = UTU$A={U}^{\mathrm{T}}U$ if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or A = LLT$A=L{L}^{\mathrm{T}}$ if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, where U$U$ is an upper triangular matrix and L$L$ is a lower triangular matrix.
3. If the leading i$i$ by i$i$ principal minor of A$A$ is not positive definite, then the function returns with info = i${\mathbf{info}}=i$. Otherwise, the factored form of A$A$ is used to estimate the condition number of the matrix A$A$. If the reciprocal of the condition number is less than machine precision, infon + 1${\mathbf{info}}\ge {\mathbf{n}}+1$ is returned as a warning, but the function still goes on to solve for X$X$ and compute error bounds as described below.
4. The system of equations is solved for X$X$ using the factored form of A$A$.
5. Iterative refinement is applied to improve the computed solution matrix and to calculate error bounds and backward error estimates for it.
6. If equilibration was used, the matrix X$X$ is premultiplied by DS ${D}_{S}$ so that it solves the original system before equilibration.

## References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia

## Parameters

### Compulsory Input Parameters

1:     fact – string (length ≥ 1)
Specifies whether or not the factorized form of the matrix A$A$ is supplied on entry, and if not, whether the matrix A$A$ should be equilibrated before it is factorized.
fact = 'F'${\mathbf{fact}}=\text{'F'}$
afb contains the factorized form of A$A$. If equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, the matrix A$A$ has been equilibrated with scaling factors given by s. ab and afb will not be modified.
fact = 'N'${\mathbf{fact}}=\text{'N'}$
The matrix A$A$ will be copied to afb and factorized.
fact = 'E'${\mathbf{fact}}=\text{'E'}$
The matrix A$A$ will be equilibrated if necessary, then copied to afb and factorized.
Constraint: fact = 'F'${\mathbf{fact}}=\text{'F'}$, 'N'$\text{'N'}$ or 'E'$\text{'E'}$.
2:     uplo – string (length ≥ 1)
If uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, the upper triangle of A$A$ is stored.
If uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, the lower triangle of A$A$ is stored.
Constraint: uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or 'L'$\text{'L'}$.
3:     kd – int64int32nag_int scalar
kd${k}_{d}$, the number of superdiagonals of the matrix A$A$ if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, or the number of subdiagonals if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$.
Constraint: kd0${\mathbf{kd}}\ge 0$.
4:     ab(ldab, : $:$) – double array
The first dimension of the array ab must be at least kd + 1${\mathbf{kd}}+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 upper or lower triangle of the symmetric band matrix A$A$, except if fact = 'F'${\mathbf{fact}}=\text{'F'}$ and equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, in which case ab must contain the equilibrated matrix DSADS${D}_{S}A{D}_{S}$.
The matrix is stored in rows 1$1$ to kd + 1${k}_{d}+1$, more precisely,
• if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, the elements of the upper triangle of A$A$ within the band must be stored with element Aij${A}_{ij}$ in ab(kd + 1 + ij,j)​ for ​max (1,jkd)ij${\mathbf{ab}}\left({k}_{d}+1+i-j,j\right)\text{​ for ​}\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,j-{k}_{d}\right)\le i\le j$;
• if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, the elements of the lower triangle of A$A$ within the band must be stored with element Aij${A}_{ij}$ in ab(1 + ij,j)​ for ​jimin (n,j + kd).${\mathbf{ab}}\left(1+i-j,j\right)\text{​ for ​}j\le i\le \mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(n,j+{k}_{d}\right)\text{.}$
5:     afb(ldafb, : $:$) – double array
The first dimension of the array afb must be at least kd + 1${\mathbf{kd}}+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)$
If fact = 'F'${\mathbf{fact}}=\text{'F'}$, afb contains the triangular factor U$U$ or L$L$ from the Cholesky factorization A = UTU$A={U}^{\mathrm{T}}U$ or A = LLT$A=L{L}^{\mathrm{T}}$ of the band matrix A$A$, in the same storage format as A$A$. If equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, afb is the factorized form of the equilibrated matrix A$A$.
6:     equed – string (length ≥ 1)
If fact = 'N'${\mathbf{fact}}=\text{'N'}$ or 'E'$\text{'E'}$, equed need not be set.
If fact = 'F'${\mathbf{fact}}=\text{'F'}$, equed must specify the form of the equilibration that was performed as follows:
• if equed = 'N'${\mathbf{equed}}=\text{'N'}$, no equilibration;
• if equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, equilibration was performed, i.e., A$A$ has been replaced by DSADS${D}_{S}A{D}_{S}$.
Constraint: if fact = 'F'${\mathbf{fact}}=\text{'F'}$, equed = 'N'${\mathbf{equed}}=\text{'N'}$ or 'Y'$\text{'Y'}$.
7:     s( : $:$) – double array
Note: the dimension of the array s must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If fact = 'N'${\mathbf{fact}}=\text{'N'}$ or 'E'$\text{'E'}$, s need not be set.
If fact = 'F'${\mathbf{fact}}=\text{'F'}$ and equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, s must contain the scale factors, DS${D}_{S}$, for A$A$; each element of s must be positive.
8:     b(ldb, : $:$) – double 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$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array b The second dimension of the arrays ab, afb, s.
n$n$, the number of linear equations, i.e., 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 array b.
r$r$, the number of right-hand sides, i.e., the number of columns of the matrix B$B$.
Constraint: nrhs0${\mathbf{nrhs}}\ge 0$.

### Input Parameters Omitted from the MATLAB Interface

ldab ldafb ldb ldx work iwork

### Output Parameters

1:     ab(ldab, : $:$) – double array
The first dimension of the array ab will be kd + 1${\mathbf{kd}}+1$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
ldabkd + 1$\mathit{ldab}\ge {\mathbf{kd}}+1$.
If fact = 'E'${\mathbf{fact}}=\text{'E'}$ and equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, ab stores DSADS${D}_{S}A{D}_{S}$.
2:     afb(ldafb, : $:$) – double array
The first dimension of the array afb will be kd + 1${\mathbf{kd}}+1$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
ldafbkd + 1$\mathit{ldafb}\ge {\mathbf{kd}}+1$.
If fact = 'N'${\mathbf{fact}}=\text{'N'}$, afb returns the triangular factor U$U$ or L$L$ from the Cholesky factorization A = UTU$A={U}^{\mathrm{T}}U$ or A = LLT$A=L{L}^{\mathrm{T}}$.
If fact = 'E'${\mathbf{fact}}=\text{'E'}$, afb returns the triangular factor U$U$ or L$L$ from the Cholesky factorization A = UTU$A={U}^{\mathrm{T}}U$ or A = LLT$A=L{L}^{\mathrm{T}}$ of the equilibrated matrix A$A$ (see the description of ab for the form of the equilibrated matrix).
3:     equed – string (length ≥ 1)
If fact = 'F'${\mathbf{fact}}=\text{'F'}$, equed is unchanged from entry.
Otherwise, if no constraints are violated, equed specifies the form of the equilibration that was performed as specified above.
4:     s( : $:$) – double array
Note: the dimension of the array s must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If fact = 'F'${\mathbf{fact}}=\text{'F'}$, s is unchanged from entry.
Otherwise, if no constraints are violated and equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, s contains the scale factors, DS${D}_{S}$, for A$A$; each element of s is positive.
5:     b(ldb, : $:$) – double array
The first dimension of the array b 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)$
ldbmax (1,n)$\mathit{ldb}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If equed = 'N'${\mathbf{equed}}=\text{'N'}$, b is not modified.
If equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, b stores DSB${D}_{S}B$.
6:     x(ldx, : $:$) – double 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)$.
If ${\mathbf{INFO}}={\mathbf{0}}$ or n + 1$\mathbf{n}+{\mathbf{1}}$, the n$n$ by r$r$ solution matrix X$X$ to the original system of equations. Note that the arrays A$A$ and B$B$ are modified on exit if equed = 'Y'${\mathbf{equed}}=\text{'Y'}$, and the solution to the equilibrated system is DS1X${D}_{S}^{-1}X$.
7:     rcond – double scalar
If no constraints are violated, an estimate of the reciprocal condition number of the matrix A$A$ (after equilibration if that is performed), computed as rcond = 1.0 / (A1A11)${\mathbf{rcond}}=1.0/\left({‖A‖}_{1}{‖{A}^{-1}‖}_{1}\right)$.
8:     ferr(nrhs_p) – double array
If ${\mathbf{INFO}}={\mathbf{0}}$ or n + 1$\mathbf{n}+{\mathbf{1}}$, an estimate of the forward error bound for each computed solution vector, such that jxj / xjferr(j)${‖{\stackrel{^}{x}}_{j}-{x}_{j}‖}_{\infty }/{‖{x}_{j}‖}_{\infty }\le {\mathbf{ferr}}\left(j\right)$ where j${\stackrel{^}{x}}_{j}$ is the j$j$th column of the computed solution returned in the array x and xj${x}_{j}$ is the corresponding column of the exact solution X$X$. The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.
9:     berr(nrhs_p) – double array
If ${\mathbf{INFO}}={\mathbf{0}}$ or n + 1$\mathbf{n}+{\mathbf{1}}$, an estimate of the component-wise relative backward error of each computed solution vector j${\stackrel{^}{x}}_{j}$ (i.e., the smallest relative change in any element of A$A$ or B$B$ that makes j${\stackrel{^}{x}}_{j}$ an exact solution).
10:   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

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_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: fact, 2: uplo, 3: n, 4: kd, 5: nrhs_p, 6: ab, 7: ldab, 8: afb, 9: ldafb, 10: equed, 11: s, 12: b, 13: ldb, 14: x, 15: ldx, 16: rcond, 17: ferr, 18: berr, 19: work, 20: iwork, 21: 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.
INFO > 0andINFON${\mathbf{INFO}}>0 \text{and} {\mathbf{INFO}}\le {\mathbf{N}}$
If info = i${\mathbf{info}}=i$ and in$i\le {\mathbf{n}}$, the leading minor of order i$i$ of A$A$ is not positive definite, so the factorization could not be completed, and the solution has not been computed. rcond = 0.0${\mathbf{rcond}}=0.0$ is returned.
W INFO = N + 1${\mathbf{INFO}}={\mathbf{N}}+1$
The triangular matrix U$U$ (or L$L$) is nonsingular, but rcond is less than machine precision, meaning that the matrix is singular to working precision. Nevertheless, the solution and error bounds are computed because there are a number of situations where the computed solution can be more accurate than the value of rcond would suggest.

## Accuracy

For each right-hand side vector b$b$, the computed solution x$x$ is the exact solution of a perturbed system of equations (A + E) x = b$\left(A+E\right)x=b$, where
• if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, |E|c(n)ε|UT||U|$|E|\le c\left(n\right)\epsilon |{U}^{\mathrm{T}}||U|$;
• if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, |E|c(n)ε|L||LT|$|E|\le c\left(n\right)\epsilon |L||{L}^{\mathrm{T}}|$,
c(n)$c\left(n\right)$ is a modest linear function of n$n$, and ε$\epsilon$ is the machine precision. See Section 10.1 of Higham (2002) for further details.
If $\stackrel{^}{x}$ is the true solution, then the computed solution x$x$ satisfies a forward error bound of the form
 ( ‖x − x̂‖∞ )/( ‖x̂‖∞ ) ≤ wc cond(A,x̂,b) $‖x-x^‖∞ ‖x^‖∞ ≤ wc cond(A,x^,b)$
where cond(A,,b) = |A1|(|A||| + |b|) / cond(A) = |A1||A|κ (A)$\mathrm{cond}\left(A,\stackrel{^}{x},b\right)={‖|{A}^{-1}|\left(|A||\stackrel{^}{x}|+|b|\right)‖}_{\infty }/{‖\stackrel{^}{x}‖}_{\infty }\le \mathrm{cond}\left(A\right)={‖|{A}^{-1}||A|‖}_{\infty }\le {\kappa }_{\infty }\left(A\right)$. If $\stackrel{^}{x}$ is the j $j$th column of X $X$, then wc ${w}_{c}$ is returned in berr(j) ${\mathbf{berr}}\left(j\right)$ and a bound on x / ${‖x-\stackrel{^}{x}‖}_{\infty }/{‖\stackrel{^}{x}‖}_{\infty }$ is returned in ferr(j) ${\mathbf{ferr}}\left(j\right)$. See Section 4.4 of Anderson et al. (1999) for further details.

When nk $n\gg k$, the factorization of A $A$ requires approximately n (k + 1)2 $n{\left(k+1\right)}^{2}$ floating point operations, where k $k$ is the number of superdiagonals.
For each right-hand side, computation of the backward error involves a minimum of 8nk $8nk$ floating point operations. Each step of iterative refinement involves an additional 12nk $12nk$ 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 equations of the form Ax = b $Ax=b$; the number is usually 4$4$ or 5$5$ and never more than 11$11$. Each solution involves approximately 4nk $4nk$ operations.
The complex analogue of this function is nag_lapack_zpbsvx (f07hp).

## Example

```function nag_lapack_dpbsvx_example
fact = 'Equilibration';
uplo = 'U';
kd = int64(1);
ab = [0, 2.68, -2.39, -2.22;
5.49, 5.63, 2.6, 5.17];
afb = zeros(2, 4);
equed = ' ';
s = zeros(4, 1);
b = [22.09, 5.1;
9.31, 30.81;
-5.24, -25.82;
11.83, 22.9];
[abOut, afbOut, equedOut, sOut, bOut, x, rcond, ferr, berr, info] = ...
nag_lapack_dpbsvx(fact, uplo, kd, ab, afb, equed, s, b)
```
```

0    2.6800   -2.3900   -2.2200
5.4900    5.6300    2.6000    5.1700

afbOut =

0    1.1438   -1.1497   -1.9635
2.3431    2.0789    1.1306    1.1465

equedOut =

N

sOut =

0.4268
0.4214
0.6202
0.4398

bOut =

22.0900    5.1000
9.3100   30.8100
-5.2400  -25.8200
11.8300   22.9000

x =

5.0000   -2.0000
-2.0000    6.0000
-3.0000   -1.0000
1.0000    4.0000

rcond =

0.0135

ferr =

1.0e-13 *

0.1996
0.2833

berr =

1.0e-15 *

0.0864
0.1105

info =

0

```
```function f07hb_example
fact = 'Equilibration';
uplo = 'U';
kd = int64(1);
ab = [0, 2.68, -2.39, -2.22;
5.49, 5.63, 2.6, 5.17];
afb = zeros(2, 4);
equed = ' ';
s = zeros(4, 1);
b = [22.09, 5.1;
9.31, 30.81;
-5.24, -25.82;
11.83, 22.9];
[abOut, afbOut, equedOut, sOut, bOut, x, rcond, ferr, berr, info] = ...
f07hb(fact, uplo, kd, ab, afb, equed, s, b)
```
```

0    2.6800   -2.3900   -2.2200
5.4900    5.6300    2.6000    5.1700

afbOut =

0    1.1438   -1.1497   -1.9635
2.3431    2.0789    1.1306    1.1465

equedOut =

N

sOut =

0.4268
0.4214
0.6202
0.4398

bOut =

22.0900    5.1000
9.3100   30.8100
-5.2400  -25.8200
11.8300   22.9000

x =

5.0000   -2.0000
-2.0000    6.0000
-3.0000   -1.0000
1.0000    4.0000

rcond =

0.0135

ferr =

1.0e-13 *

0.1996
0.2833

berr =

1.0e-15 *

0.0864
0.1105

info =

0

```