# NAG Library Routine Document

## 1Purpose

f03bhf computes the determinant of a $n$ by $n$ symmetric positive definite banded matrix $A$ that has been stored in band-symmetric storage. f07hdf (dpbtrf) must be called first to supply the Cholesky factorized form. The storage (upper or lower triangular) used by f07hdf (dpbtrf) 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
#include <nagmk26.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)

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

## 4References

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 (dpbtrf).
${\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}$ – IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}>0$.
3:     $\mathbf{kd}$ – IntegerInput
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) arrayInput
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 (dpbtrf).
5:     $\mathbf{ldab}$ – IntegerInput
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}$ – IntegerOutput
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}$ – IntegerInput/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value  is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value  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$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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.

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)