# NAG FL Interfacef04mcf (real_​posdef_​vband_​solve)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f04mcf 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 f01mcf. Related systems may also be solved.

## 2Specification

Fortran Interface
 Subroutine f04mcf ( n, al, lal, d, nrow, ir, b, ldb, x, ldx,
 Integer, Intent (In) :: n, lal, nrow(n), ir, ldb, iselct, ldx Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: al(lal), d(*), b(ldb,ir) Real (Kind=nag_wp), Intent (Inout) :: x(ldx,ir)
#include <nag.h>
 void f04mcf_ (const Integer *n, const double al[], const Integer *lal, const double d[], const Integer nrow[], const Integer *ir, const double b[], const Integer *ldb, const Integer *iselct, double x[], const Integer *ldx, Integer *ifail)
The routine may be called by the names f04mcf or nagf_linsys_real_posdef_vband_solve.

## 3Description

The normal use of this routine is the solution of the systems $AX=B$, following a call of f01mcf to determine the Cholesky factorization $A=LD{L}^{\mathrm{T}}$ of the symmetric positive definite variable-bandwidth matrix $A$.
However, the routine may be used to solve any one of the following systems of linear algebraic equations:
1. 1.$LD{L}^{\mathrm{T}}X=B$ (usual system),
2. 2.$LDX=B$ (lower triangular system),
3. 3.$D{L}^{\mathrm{T}}X=B$ (upper triangular system),
4. 4.$L{L}^{\mathrm{T}}X=B$
5. 5.$LX=B$ (unit lower triangular system),
6. 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. 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.

## 4References

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

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $L$.
Constraint: ${\mathbf{n}}\ge 1$.
2: $\mathbf{al}\left({\mathbf{lal}}\right)$Real (Kind=nag_wp) array Input
On entry: the elements within the envelope of the lower triangular matrix $L$, taken in row by row order, as returned by f01mcf. The unit diagonal elements of $L$ must be stored explicitly.
3: $\mathbf{lal}$Integer Input
On entry: the dimension of the array al as declared in the (sub)program from which f04mcf is called.
Constraint: ${\mathbf{lal}}\ge {\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\cdots +{\mathbf{nrow}}\left(n\right)$.
4: $\mathbf{d}\left(*\right)$Real (Kind=nag_wp) array Input
Note: the dimension of the array d must be at least $1$ if ${\mathbf{iselct}}\ge 4$, and at least ${\mathbf{n}}$ otherwise.
On entry: the diagonal elements of the diagonal matrix $D$. d is not referenced if ${\mathbf{iselct}}\ge 4$.
5: $\mathbf{nrow}\left({\mathbf{n}}\right)$Integer array Input
On entry: ${\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$.
6: $\mathbf{ir}$Integer Input
On entry: $r$, the number of right-hand sides.
Constraint: ${\mathbf{ir}}\ge 1$.
7: $\mathbf{b}\left({\mathbf{ldb}},{\mathbf{ir}}\right)$Real (Kind=nag_wp) array Input
On entry: the $n×r$ right-hand side matrix $B$. See also Section 9.
8: $\mathbf{ldb}$Integer Input
On entry: the first dimension of the array b as declared in the (sub)program from which f04mcf is called.
Constraint: ${\mathbf{ldb}}\ge {\mathbf{n}}$.
9: $\mathbf{iselct}$Integer Input
On entry: 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$.
10: $\mathbf{x}\left({\mathbf{ldx}},{\mathbf{ir}}\right)$Real (Kind=nag_wp) array Output
On exit: the $n×r$ solution matrix $X$. See also Section 9.
11: $\mathbf{ldx}$Integer Input
On entry: the first dimension of the array x as declared in the (sub)program from which f04mcf is called.
Constraint: ${\mathbf{ldx}}\ge {\mathbf{n}}$.
12: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, $I=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nrow}}\left(I\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nrow}}\left(I\right)\ge 1$ and ${\mathbf{nrow}}\left(I\right)\le I$.
On entry, ${\mathbf{lal}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nrow}}\left(1\right)+\cdots +{\mathbf{nrow}}\left({\mathbf{n}}\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lal}}\ge {\mathbf{nrow}}\left(1\right)+\cdots +{\mathbf{nrow}}\left({\mathbf{n}}\right)$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 1$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{ir}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ir}}\ge 1$.
On entry, ${\mathbf{ldb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldb}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{ldx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldx}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{iselct}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{iselct}}\ge 1$ and ${\mathbf{iselct}}\le 6$.
${\mathbf{ifail}}=4$
On entry, $I=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{d}}\left(I\right)\ne 0.0$.
${\mathbf{ifail}}=5$
At least one diagonal entry of al is not unit.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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

## 8Parallelism and Performance

f04mcf is not threaded in any implementation.

The time taken by f04mcf is approximately proportional to $pr$, where $p={\mathbf{nrow}}\left(1\right)+{\mathbf{nrow}}\left(2\right)+\cdots +{\mathbf{nrow}}\left(n\right)$.
Unless otherwise stated in the Users' Note for your implementation, the routine may be called with the same actual array supplied for the arguments b and x, in which case the solution matrix will overwrite the right-hand side matrix. However this is not standard Fortran and may not work in all implementations.

## 10Example

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

### 10.1Program Text

Program Text (f04mcfe.f90)

### 10.2Program Data

Program Data (f04mcfe.d)

### 10.3Program Results

Program Results (f04mcfe.r)