F04 Chapter Contents
F04 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF04MCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

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.

## 2  Specification

 SUBROUTINE F04MCF ( N, AL, LAL, D, NROW, IR, B, LDB, ISELCT, X, LDX, IFAIL)
 INTEGER N, LAL, NROW(N), IR, LDB, ISELCT, LDX, IFAIL REAL (KIND=nag_wp) AL(LAL), D(*), B(LDB,IR), X(LDX,IR)

## 3  Description

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. $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 Section 9 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.
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5  Parameters

1:     N – INTEGERInput
On entry: $n$, the order of the matrix $L$.
Constraint: ${\mathbf{N}}\ge 1$.
2:     AL(LAL) – REAL (KIND=nag_wp) arrayInput
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:     LAL – INTEGERInput
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)+\dots +{\mathbf{NROW}}\left(n\right)$.
4:     D($*$) – REAL (KIND=nag_wp) arrayInput
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:     NROW(N) – INTEGER arrayInput
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:     IR – INTEGERInput
On entry: $r$, the number of right-hand sides.
Constraint: ${\mathbf{IR}}\ge 1$.
7:     B(LDB,IR) – REAL (KIND=nag_wp) arrayInput
On entry: the $n$ by $r$ right-hand side matrix $B$. See also Section 8.
8:     LDB – INTEGERInput
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:     ISELCT – INTEGERInput
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:   X(LDX,IR) – REAL (KIND=nag_wp) arrayOutput
On exit: the $n$ by $r$ solution matrix $X$. See also Section 8.
11:   LDX – INTEGERInput
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:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ 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).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{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, ${\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 ${\mathbf{LDB}}<{\mathbf{N}}$, or ${\mathbf{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.

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

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

### 9.1  Program Text

Program Text (f04mcfe.f90)

### 9.2  Program Data

Program Data (f04mcfe.d)

### 9.3  Program Results

Program Results (f04mcfe.r)