# NAG CL Interfacef04mcc (real_​posdef_​vband_​solve)

## 1Purpose

f04mcc 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 f01mcc. Related systems may also be solved.

## 2Specification

 #include
 void f04mcc (Nag_SolveSystem selct, Integer n, Integer nrhs, const double al[], Integer lal, const double d[], const Integer row[], const double b[], Integer tdb, double x[], Integer tdx, NagError *fail)
The function may be called by the names: f04mcc, nag_linsys_real_posdef_vband_solve or nag_real_cholesky_skyline_solve.

## 3Description

The normal use of f04mcc is the solution of the systems $AX=B$, following a call of f01mcc 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:
 $LDLT X =B ​ (usual system)$ (1)
 $LDX =B ​ (lower triangular system)$ (2)
 $DLT X =B ​ (upper triangular system)$ (3)
 $LLT X =B$ (4)
 $LX =B ​ (unit lower triangular system)$ (5)
 $LT X =B ​ (unit upper triangular system)$ (6)
$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 10 for an example). The width ${\mathbf{row}}\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

## 5Arguments

1: $\mathbf{selct}$Nag_SolveSystem Input
On entry: selct must specify the type of system to be solved, as follows:
• if ${\mathbf{selct}}=\mathrm{Nag_LDLTX}$: solve ${LDL}^{TX}=B$;
• if ${\mathbf{selct}}=\mathrm{Nag_LDX}$: solve $LDX=B$;
• if ${\mathbf{selct}}=\mathrm{Nag_DLTX}$: solve ${DL}^{\mathrm{T}}X=B$;
• if ${\mathbf{selct}}=\mathrm{Nag_LLTX}$: solve ${LL}^{\mathrm{T}}X=B$;
• if ${\mathbf{selct}}=\mathrm{Nag_LX}$: solve $LX=B$;
• if ${\mathbf{selct}}=\mathrm{Nag_LTX}$: solve ${L}^{\mathrm{T}}X=B$.
Constraint: ${\mathbf{selct}}=\mathrm{Nag_LDLTX}$, $\mathrm{Nag_LDX}$, $\mathrm{Nag_DLTX}$, $\mathrm{Nag_LLTX}$, $\mathrm{Nag_LX}$ or $\mathrm{Nag_LTX}$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $L$.
Constraint: ${\mathbf{n}}\ge 1$.
3: $\mathbf{nrhs}$Integer Input
On entry: $r$, the number of right-hand sides.
Constraint: ${\mathbf{nrhs}}\ge 1$.
4: $\mathbf{al}\left[{\mathbf{lal}}\right]$const double Input
On entry: the elements within the envelope of the lower triangular matrix $L$, taken in row by row order, as returned by f01mcc. The unit diagonal elements of $L$ must be stored explicitly.
5: $\mathbf{lal}$Integer Input
On entry: the dimension of the array al.
Constraint: ${\mathbf{lal}}\ge {\mathbf{row}}\left[0\right]+{\mathbf{row}}\left[1\right]+\cdots +{\mathbf{row}}\left[n-1\right]$.
6: $\mathbf{d}\left[{\mathbf{n}}\right]$const double Input
On entry: the diagonal elements of the diagonal matrix $D$. d is not referenced if ${\mathbf{selct}}=\mathrm{Nag_LLTX}$, $\mathrm{Nag_LX}$ or $\mathrm{Nag_LTX}$
7: $\mathbf{row}\left[{\mathbf{n}}\right]$const Integer Input
On entry: ${\mathbf{row}}\left[i\right]$ must contain the width of row $i$ of $L$, i.e., the number of elements between the first (left-most) nonzero element and the element on the diagonal, inclusive.
Constraint: $1\le {\mathbf{row}}\left[i\right]\le i+1$ for $i=0,1,\dots ,n-1$.
8: $\mathbf{b}\left[{\mathbf{n}}×{\mathbf{tdb}}\right]$const double Input
Note: the $\left(i,j\right)$th element of the matrix $B$ is stored in ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{tdb}}+j-1\right]$.
On entry: the $n$ by $r$ right-hand side matrix $B$. See also Section 9.
9: $\mathbf{tdb}$Integer Input
On entry: the stride separating matrix column elements in the array b.
Constraint: ${\mathbf{tdb}}\ge {\mathbf{nrhs}}$.
10: $\mathbf{x}\left[{\mathbf{n}}×{\mathbf{tdx}}\right]$double Output
Note: the $\left(i,j\right)$th element of the matrix $X$ is stored in ${\mathbf{x}}\left[\left(i-1\right)×{\mathbf{tdx}}+j-1\right]$.
On exit: the $n$ by $r$ solution matrix $X$. See also Section 9.
11: $\mathbf{tdx}$Integer Input
On entry: the stride separating matrix column elements in the array x.
Constraint: ${\mathbf{tdx}}\ge {\mathbf{nrhs}}$.
12: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_2_INT_ARG_GT
On entry, ${\mathbf{row}}\left[i\right]=〈\mathit{\text{value}}〉$ while $i=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{row}}\left[i\right]\le i+1$.
NE_2_INT_ARG_LT
On entry, ${\mathbf{lal}}=〈\mathit{\text{value}}〉$ while ${\mathbf{row}}\left[0\right]+\cdots +{\mathbf{row}}\left[n-1\right]=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{lal}}\ge {\mathbf{row}}\left[0\right]+\cdots +{\mathbf{row}}\left[n-1\right]$.
On entry, ${\mathbf{tdb}}=〈\mathit{\text{value}}〉$ while ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdb}}\ge {\mathbf{nrhs}}$.
On entry, ${\mathbf{tdx}}=〈\mathit{\text{value}}〉$ while ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdx}}\ge {\mathbf{nrhs}}$.
On entry, argument selct had an illegal value.
NE_INT_ARG_LT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
On entry, ${\mathbf{nrhs}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nrhs}}\ge 1$.
On entry, ${\mathbf{row}}\left[〈\mathit{\text{value}}〉\right]$ must not be less than 1: ${\mathbf{row}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.
NE_NOT_UNIT_DIAG
The lower triangular matrix $L$ has at least one diagonal element which is not equal to unity. The first non-unit element has been located in the array ${\mathbf{al}}\left[〈\mathit{\text{value}}〉\right]$.
NE_ZERO_DIAG
The diagonal matrix $D$ is singular as it has at least one zero element. The first zero element has been located in the array ${\mathbf{d}}\left[〈\mathit{\text{value}}〉\right]$.

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

f04mcc is not threaded in any implementation.

The time taken by f04mcc is approximately proportional to $pr$, where $p={\mathbf{row}}\left[0\right]+{\mathbf{row}}\left[1\right]+\cdots +{\mathbf{row}}\left[n-1\right]$.
The function 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.

## 10Example

To solve 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 0-3 00 -24 51 -39 46 -67 .$
Here $A$ is symmetric and positive definite and must first be factorized by f01mcc.

### 10.1Program Text

Program Text (f04mcce.c)

### 10.2Program Data

Program Data (f04mcce.d)

### 10.3Program Results

Program Results (f04mcce.r)