F03 Chapter Contents
F03 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF03ACF

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

F03ACF calculates the determinant of a real symmetric positive definite band matrix using a Cholesky factorization.

## 2  Specification

 SUBROUTINE F03ACF ( A, LDA, N, M, DET, RL, LDRL, M1, IFAIL)
 INTEGER LDA, N, M, LDRL, M1, IFAIL REAL (KIND=nag_wp) A(LDA,M1), DET, RL(LDRL,M1)

## 3  Description

The determinant of $A$ is calculated using the Cholesky factorization $A=L{L}^{\mathrm{T}}$, where $L$ is a lower triangular band matrix. The determinant of $A$ is the product of the squares of the diagonal elements of $L$.

## 4  References

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

## 5  Parameters

1:     A(LDA,M1) – REAL (KIND=nag_wp) arrayInput
On entry: the lower triangle of the $n$ by $n$ positive definite symmetric band matrix $A$, with the diagonal of the matrix stored in the $\left(m+1\right)$th column of the array, and the $m$ subdiagonals within the band stored in the first $m$ columns of the array. Each row of the matrix is stored in the corresponding row of the array. For example, if $n=5$ and $m=2$, the storage scheme is
 $* * a11 * a21 a22 a31 a32 a33 a42 a43 a44 a53 a54 a55 .$
The elements in the top left corner of the array are not used. The following code may be used to assign elements within the band of the lower triangle of the matrix to the correct elements of the array:
` DO 20 I = 1, N DO 10 J = MAX(1,I-M), I A(I,J-I+M+1) = matrix(I,J) 10 CONTINUE 20 CONTINUE `
2:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F03ACF is called.
Constraint: ${\mathbf{LDA}}\ge {\mathbf{N}}$.
3:     N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
4:     M – INTEGERInput
On entry: $m$, the number of subdiagonals within the band of $A$.
5:     DET – REAL (KIND=nag_wp)Output
On exit: the determinant of $A$.
6:     RL(LDRL,M1) – REAL (KIND=nag_wp) arrayOutput
On exit: the lower triangular matrix $L$, stored in the same way as $A$, except that in place of the diagonal elements, their reciprocals are stored.
7:     LDRL – INTEGERInput
On entry: the first dimension of the array RL as declared in the (sub)program from which F03ACF is called.
Constraint: ${\mathbf{LDRL}}\ge {\mathbf{N}}$.
8:     M1 – INTEGERInput
On entry: the value $m+1$.
9:     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$
The matrix $A$ is not positive definite, possibly due to rounding errors.
${\mathbf{IFAIL}}=2$
Overflow. The value of the determinant is too large to be held in the computer.
${\mathbf{IFAIL}}=3$
Underflow. The value of the determinant is too small to be held in the computer.

## 7  Accuracy

The accuracy of the determinant depends on the conditioning of the original matrix. For a detailed error analysis see page 54 of Wilkinson and Reinsch (1971).

The time taken by F03ACF is approximately proportional to $n{\left(m+1\right)}^{2}$.
This routine should only be used when $m\ll n$ since as $m$ approaches $n$, it becomes less efficient to take advantage of the band form.

## 9  Example

This example calculates the determinant of the real symmetric positive definite band matrix
 $5 -4 1 -4 6 -4 1 1 -4 6 -4 1 1 -4 6 -4 1 1 -4 6 -4 1 1 -4 6 -4 1 -4 5 .$

### 9.1  Program Text

Program Text (f03acfe.f90)

### 9.2  Program Data

Program Data (f03acfe.d)

### 9.3  Program Results

Program Results (f03acfe.r)