# NAG FL Interfacef03bhf (real_​band_​sym)

## 1Purpose

f03bhf computes the determinant of an $n$ by $n$ symmetric positive definite banded matrix $A$ that has been stored in band-symmetric storage. f07hdf must be called first to supply the Cholesky factorized form. The storage (upper or lower triangular) used by f07hdf is relevant as this determines which elements of the stored factorized form are referenced.

## 2Specification

Fortran Interface
 Subroutine f03bhf ( uplo, n, kd, ab, ldab, d, id,
 Integer, Intent (In) :: n, kd, ldab Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: id Real (Kind=nag_wp), Intent (In) :: ab(ldab,*) Real (Kind=nag_wp), Intent (Out) :: d Character (1), Intent (In) :: uplo
C Header Interface
#include <nag.h>
 void f03bhf_ (const char *uplo, const Integer *n, const Integer *kd, const double ab[], const Integer *ldab, double *d, Integer *id, Integer *ifail, const Charlen length_uplo)
The routine may be called by the names f03bhf or nagf_det_real_band_sym.

## 3Description

The determinant of $A$ is calculated using the Cholesky factorization $A={U}^{\mathrm{T}}U$, where $U$ is an upper triangular band matrix, or $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 $U$ or $L$.
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5Arguments

1: $\mathbf{uplo}$Character(1) Input
On entry: indicates whether the upper or lower triangular part of $A$ was stored and how it was factorized. This should not be altered following a call to f07hdf.
${\mathbf{uplo}}=\text{'U'}$
The upper triangular part of $A$ was originally stored and $A$ was factorized as ${U}^{\mathrm{T}}U$ where $U$ is upper triangular.
${\mathbf{uplo}}=\text{'L'}$
The lower triangular part of $A$ was originally stored and $A$ was factorized as $L{L}^{\mathrm{T}}$ where $L$ is lower triangular.
Constraint: ${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}>0$.
3: $\mathbf{kd}$Integer Input
On entry: ${k}_{d}$, the number of superdiagonals or subdiagonals of the matrix $A$.
Constraint: ${\mathbf{kd}}\ge 0$.
4: $\mathbf{ab}\left({\mathbf{ldab}},*\right)$Real (Kind=nag_wp) array Input
Note: the second dimension of the array ab must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the Cholesky factor of $A$, as returned by f07hdf.
5: $\mathbf{ldab}$Integer Input
On entry: the first dimension of the array ab as declared in the subprogram from which f03bhf is called.
Constraint: ${\mathbf{ldab}}\ge {\mathbf{kd}}+1$.
6: $\mathbf{d}$Real (Kind=nag_wp) Output
7: $\mathbf{id}$Integer Output
On exit: the determinant of $A$ is given by ${\mathbf{d}}×{2.0}^{{\mathbf{id}}}$. It is given in this form to avoid overflow or underflow.
8: $\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, ${\mathbf{uplo}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{uplo}}=\text{'L'}$ or $\text{'U'}$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}>0$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{kd}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{kd}}\ge 0$.
${\mathbf{ifail}}=5$
On entry, ${\mathbf{ldab}}=〈\mathit{\text{value}}〉$ and ${\mathbf{kd}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ldab}}\ge {\mathbf{kd}}+1$.
${\mathbf{ifail}}=6$
The matrix $A$ is not positive definite.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
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 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).

## 8Parallelism and Performance

f03bhf is not threaded in any implementation.

## 9Further Comments

The time taken by f03bhf is approximately proportional to $n$.
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.

## 10Example

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

### 10.1Program Text

Program Text (f03bhfe.f90)

### 10.2Program Data

Program Data (f03bhfe.d)

### 10.3Program Results

Program Results (f03bhfe.r)