F03 Chapter Contents
F03 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF03BHF

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

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.

## 2  Specification

 SUBROUTINE F03BHF ( UPLO, N, KD, AB, LDAB, D, ID, IFAIL)
 INTEGER N, KD, LDAB, ID, IFAIL REAL (KIND=nag_wp) AB(LDAB,*), D CHARACTER(1) UPLO

## 3  Description

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

## 4  References

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

## 5  Parameters

1:     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:     N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}>0$.
3:     KD – INTEGERInput
On entry: ${k}_{d}$, the number of superdiagonals or subdiagonals of the matrix $A$.
Constraint: ${\mathbf{KD}}\ge 0$.
4:     AB(LDAB,$*$) – 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:     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:     D – REAL (KIND=nag_wp)Output
7:     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:     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{UPLO}}\ne \text{'L'}$ or $\text{'U'}$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{N}}<1$.
${\mathbf{IFAIL}}=3$
 On entry, ${\mathbf{KD}}<0$.
${\mathbf{IFAIL}}=5$
 On entry, ${\mathbf{LDAB}}<{\mathbf{KD}}+1$.
${\mathbf{IFAIL}}=6$
The matrix $A$ is not positive definite.

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

## 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 (f03bhfe.f90)

### 9.2  Program Data

Program Data (f03bhfe.d)

### 9.3  Program Results

Program Results (f03bhfe.r)