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$, where $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$, following a call of nag_matop_real_vband_posdef_fac (f01mc) to determine the Cholesky factorization $A=LD{L}^{\mathrm{T}}$ of the symmetric positive definite variable-bandwidth matrix $A$.
However, the function may be used to solve any one of the following systems of linear algebraic equations:
 1 $LD{L}^{\mathrm{T}}X=B$ (usual system), 2 $LDX=B$ (lower triangular system), 3 $D{L}^{\mathrm{T}}X=B$ (upper triangular system), 4 $L{L}^{\mathrm{T}}X=B$ 5 $LX=B$ (unit lower triangular system), 6 ${L}^{\mathrm{T}}X=B$ (unit upper triangular system).
$L$ denotes a unit lower triangular variable-bandwidth matrix of order $n$, $D$ a diagonal matrix of order $n$, and $B$ a set of right-hand sides.
The matrix $L$ is represented by the elements lying within its envelope, i.e., between the first nonzero of each row and the diagonal (see Example for an example). The width ${\mathbf{nrow}}\left(i\right)$ of the $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:     $\mathrm{al}\left({\mathbf{lal}}\right)$ – double array
The elements within the envelope of the lower triangular matrix $L$, taken in row by row order, as returned by nag_matop_real_vband_posdef_fac (f01mc). The unit diagonal elements of $L$ must be stored explicitly.
2:     $\mathrm{d}\left(:\right)$ – double array
The dimension of the array d must be at least $1$ if ${\mathbf{iselct}}\ge 4$, and at least ${\mathbf{n}}$ otherwise
The diagonal elements of the diagonal matrix $D$. d is not referenced if ${\mathbf{iselct}}\ge 4$.
3:     $\mathrm{nrow}\left({\mathbf{n}}\right)$int64int32nag_int array
${\mathbf{nrow}}\left(i\right)$ must contain the width of row $i$ of $L$, i.e., the number of elements between the first (leftmost) nonzero element and the element on the diagonal, inclusive.
Constraint: $1\le {\mathbf{nrow}}\left(i\right)\le i$.
4:     $\mathrm{b}\left(\mathit{ldb},{\mathbf{ir}}\right)$ – double array
ldb, the first dimension of the array, must satisfy the constraint $\mathit{ldb}\ge {\mathbf{n}}$.
The $n$ by $r$ right-hand side matrix $B$. See also Further Comments.
5:     $\mathrm{iselct}$int64int32nag_int scalar
Must specify the type of system to be solved, as follows:
${\mathbf{iselct}}=1$
Solve $LD{L}^{\mathrm{T}}X=B$.
${\mathbf{iselct}}=2$
Solve $LDX=B$.
${\mathbf{iselct}}=3$
Solve $D{L}^{\mathrm{T}}X=B$.
${\mathbf{iselct}}=4$
Solve $L{L}^{\mathrm{T}}X=B$.
${\mathbf{iselct}}=5$
Solve $LX=B$.
${\mathbf{iselct}}=6$
Solve ${L}^{\mathrm{T}}X=B$.
Constraint: ${\mathbf{iselct}}=1$, $2$, $3$, $4$, $5$ or $6$.

Optional Input Parameters

1:     $\mathrm{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$, the order of the matrix $L$.
Constraint: ${\mathbf{n}}\ge 1$.
2:     $\mathrm{lal}$int64int32nag_int scalar
Default: the dimension of the array al.
The dimension of the array al.
Constraint: ${\mathbf{lal}}\ge {\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\dots +{\mathbf{nrow}}\left(n\right)$.
3:     $\mathrm{ir}$int64int32nag_int scalar
Default: the second dimension of the array b.
$r$, the number of right-hand sides.
Constraint: ${\mathbf{ir}}\ge 1$.

Output Parameters

1:     $\mathrm{x}\left(\mathit{ldx},{\mathbf{ir}}\right)$ – double array
The $n$ by $r$ solution matrix $X$. See also Further Comments.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{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:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}<1$, or for some $i$, ${\mathbf{nrow}}\left(i\right)<1$ or ${\mathbf{nrow}}\left(i\right)>i$, or ${\mathbf{lal}}<{\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\cdots +{\mathbf{nrow}}\left({\mathbf{n}}\right)$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{ir}}<1$, or $\mathit{ldb}<{\mathbf{n}}$, or $\mathit{ldx}<{\mathbf{n}}$.
${\mathbf{ifail}}=3$
 On entry, ${\mathbf{iselct}}<1$, or ${\mathbf{iselct}}>6$.
${\mathbf{ifail}}=4$
The diagonal matrix $D$ is singular, i.e., at least one of the elements of d is zero. This can only occur if ${\mathbf{iselct}}\le 3$.
${\mathbf{ifail}}=5$
At least one of the diagonal elements of $L$ is not equal to unity.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

Accuracy

The usual backward error analysis of the solution of triangular system applies: each computed solution vector is exact for slightly perturbed matrices $L$ and $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$, where $p={\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\cdots +{\mathbf{nrow}}\left(n\right)$.

Example

This example solves the system of equations $AX=B$, where
 $A= 1 2 0 0 5 0 2 5 3 0 14 0 0 3 13 0 18 0 0 0 0 16 8 24 5 14 18 8 55 17 0 0 0 24 17 77 and B= 6 -10 15 -21 11 -3 0 24 51 -39 46 67$
Here $A$ is symmetric and positive definite and must first be factorized by nag_matop_real_vband_posdef_fac (f01mc).
```function f04mc_example

fprintf('f04mc example results\n\n');

a = [1;
2;     5;
3;     13;
16;
5;    14;     18;      8;     55;
24;     17;     77];
nrow = [int64(1);  2; 2; 1; 5; 3];

% Factorize
[L, D, ifail] = f01mc(a, nrow);

% Solve Ax = b
b = [  6.0 -10.0;
15.0 -21.0;
11.0  -3.0;
0.0  24.0;
51.0 -39.0;
46.0  67.0];
iselct = int64(1);
[x, ifail] = f04mc(L, D, nrow, b, iselct);

disp('Solution');
disp(x);

```
```f04mc example results

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

```