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_linsys_real_posdef_vband_solve (f04mc)

## Purpose

nag_linsys_real_posdef_vband_solve (f04mc) computes the approximate solution of a system of real linear equations with multiple right-hand sides, AX = B$AX=B$, where A$A$ is a symmetric positive definite variable-bandwidth matrix, which has previously been factorized by nag_matop_real_vband_posdef_fac (f01mc). Related systems may also be solved.

## Syntax

[x, ifail] = f04mc(al, d, nrow, b, iselct, 'n', n, 'lal', lal, 'ir', ir)
[x, ifail] = nag_linsys_real_posdef_vband_solve(al, d, nrow, b, iselct, 'n', n, 'lal', lal, 'ir', ir)

## Description

The normal use of this function is the solution of the systems AX = B$AX=B$, following a call of nag_matop_real_vband_posdef_fac (f01mc) to determine the Cholesky factorization A = LDLT$A=LD{L}^{\mathrm{T}}$ of the symmetric positive definite variable-bandwidth matrix A$A$.
However, the function may be used to solve any one of the following systems of linear algebraic equations:
1. LDLTX = B$LD{L}^{\mathrm{T}}X=B$ (usual system),
2. LDX = B$LDX=B$ (lower triangular system),
3. DLTX = B$D{L}^{\mathrm{T}}X=B$ (upper triangular system),
4. LLTX = B$L{L}^{\mathrm{T}}X=B$
5. LX = B$LX=B$ (unit lower triangular system),
6. LTX = B${L}^{\mathrm{T}}X=B$ (unit upper triangular system).
L$L$ denotes a unit lower triangular variable-bandwidth matrix of order n$n$, D$D$ a diagonal matrix of order n$n$, and B$B$ a set of right-hand sides.
The matrix L$L$ is represented by the elements lying within its envelope, i.e., between the first nonzero of each row and the diagonal (see Section [Example] for an example). The width nrow(i)${\mathbf{nrow}}\left(i\right)$ of the i$i$th row is the number of elements between the first nonzero element and the element on the diagonal inclusive.

## References

Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## Parameters

### Compulsory Input Parameters

1:     al(lal) – double array
lal, the dimension of the array, must satisfy the constraint lalnrow(1) + nrow(2) + + nrow(n)${\mathbf{lal}}\ge {\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\dots +{\mathbf{nrow}}\left(n\right)$.
The elements within the envelope of the lower triangular matrix L$L$, taken in row by row order, as returned by nag_matop_real_vband_posdef_fac (f01mc). The unit diagonal elements of L$L$ must be stored explicitly.
2:     d( : $:$) – double array
Note: the dimension of the array d must be at least 1$1$ if iselct4${\mathbf{iselct}}\ge 4$, and at least n${\mathbf{n}}$ otherwise.
The diagonal elements of the diagonal matrix D$D$. d is not referenced if iselct4${\mathbf{iselct}}\ge 4$.
3:     nrow(n) – int64int32nag_int array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
nrow(i)${\mathbf{nrow}}\left(i\right)$ must contain the width of row i$i$ of L$L$, i.e., the number of elements between the first (leftmost) nonzero element and the element on the diagonal, inclusive.
Constraint: 1nrow(i)i$1\le {\mathbf{nrow}}\left(i\right)\le i$.
4:     b(ldb,ir) – double array
ldb, the first dimension of the array, must satisfy the constraint ldbn$\mathit{ldb}\ge {\mathbf{n}}$.
The n$n$ by r$r$ right-hand side matrix B$B$. See also Section [Further Comments].
5:     iselct – int64int32nag_int scalar
Must specify the type of system to be solved, as follows:
iselct = 1${\mathbf{iselct}}=1$
Solve LDLTX = B$LD{L}^{\mathrm{T}}X=B$.
iselct = 2${\mathbf{iselct}}=2$
Solve LDX = B$LDX=B$.
iselct = 3${\mathbf{iselct}}=3$
Solve DLTX = B$D{L}^{\mathrm{T}}X=B$.
iselct = 4${\mathbf{iselct}}=4$
Solve LLTX = B$L{L}^{\mathrm{T}}X=B$.
iselct = 5${\mathbf{iselct}}=5$
Solve LX = B$LX=B$.
iselct = 6${\mathbf{iselct}}=6$
Solve LTX = B${L}^{\mathrm{T}}X=B$.
Constraint: iselct = 1${\mathbf{iselct}}=1$, 2$2$, 3$3$, 4$4$, 5$5$ or 6$6$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array nrow and the first dimension of the array b. (An error is raised if these dimensions are not equal.)
n$n$, the order of the matrix L$L$.
Constraint: n1${\mathbf{n}}\ge 1$.
2:     lal – int64int32nag_int scalar
Default: The dimension of the array al.
The dimension of the array al as declared in the (sub)program from which nag_linsys_real_posdef_vband_solve (f04mc) is called.
Constraint: lalnrow(1) + nrow(2) + + nrow(n)${\mathbf{lal}}\ge {\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\dots +{\mathbf{nrow}}\left(n\right)$.
3:     ir – int64int32nag_int scalar
Default: The second dimension of the array b.
r$r$, the number of right-hand sides.
Constraint: ir1${\mathbf{ir}}\ge 1$.

ldb ldx

### Output Parameters

1:     x(ldx,ir) – double array
ldxn$\mathit{ldx}\ge {\mathbf{n}}$.
The n$n$ by r$r$ solution matrix X$X$. See also Section [Further Comments].
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 1${\mathbf{n}}<1$, or for some i$i$, nrow(i) < 1${\mathbf{nrow}}\left(i\right)<1$ or nrow(i) > i${\mathbf{nrow}}\left(i\right)>i$, or lal < nrow(1) + nrow(2) + ⋯ + nrow(n)${\mathbf{lal}}<{\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\cdots +{\mathbf{nrow}}\left({\mathbf{n}}\right)$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, ir < 1${\mathbf{ir}}<1$, or ldb < n$\mathit{ldb}<{\mathbf{n}}$, or ldx < n$\mathit{ldx}<{\mathbf{n}}$.
ifail = 3${\mathbf{ifail}}=3$
 On entry, iselct < 1${\mathbf{iselct}}<1$, or iselct > 6${\mathbf{iselct}}>6$.
ifail = 4${\mathbf{ifail}}=4$
The diagonal matrix D$D$ is singular, i.e., at least one of the elements of d is zero. This can only occur if iselct3${\mathbf{iselct}}\le 3$.
ifail = 5${\mathbf{ifail}}=5$
At least one of the diagonal elements of L$L$ is not equal to unity.

## Accuracy

The usual backward error analysis of the solution of triangular system applies: each computed solution vector is exact for slightly perturbed matrices L$L$ and D$D$, as appropriate (see pages 25–27 and 54–55 of Wilkinson and Reinsch (1971)).

The time taken by nag_linsys_real_posdef_vband_solve (f04mc) is approximately proportional to pr$pr$, where p = nrow(1) + nrow(2) + + nrow(n)$p={\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\cdots +{\mathbf{nrow}}\left(n\right)$.

## Example

```function nag_linsys_real_posdef_vband_solve_example
al = [1;
2;
1;
3;
1;
1;
5;
4;
1.5;
0.5;
1;
1.5;
5;
1];
d = [1;
1;
4;
16;
1;
16];
nrow = [int64(1);2;2;1;5;3];
b = [6, -10;
15, -21;
11, -3;
0, 24;
51, -39;
46, 67];
iselct = int64(1);
[x, ifail] = nag_linsys_real_posdef_vband_solve(al, d, nrow, b, iselct)
```
```

x =

-3     4
2    -2
-1     3
-2     1
1    -2
1     1

ifail =

0

```
```function f04mc_example
al = [1;
2;
1;
3;
1;
1;
5;
4;
1.5;
0.5;
1;
1.5;
5;
1];
d = [1;
1;
4;
16;
1;
16];
nrow = [int64(1);2;2;1;5;3];
b = [6, -10;
15, -21;
11, -3;
0, 24;
51, -39;
46, 67];
iselct = int64(1);
[x, ifail] = f04mc(al, d, nrow, b, iselct)
```
```

x =

-3     4
2    -2
-1     3
-2     1
1    -2
1     1

ifail =

0

```