# NAG C Library Function Document

## 1Purpose

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

## 2Specification

 #include #include
 void nag_det_real_band_sym (Nag_OrderType order, Nag_UploType uplo, Integer n, Integer kd, const double ab[], Integer pdab, double *d, Integer *id, NagError *fail)

## 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{order}$Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{uplo}$Nag_UploTypeInput
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 nag_dpbtrf (f07hdc).
${\mathbf{uplo}}=\mathrm{Nag_Upper}$
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}}=\mathrm{Nag_Lower}$
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}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
3:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}>0$.
4:    $\mathbf{kd}$IntegerInput
On entry: ${k}_{d}$, the number of superdiagonals or subdiagonals of the matrix $A$.
Constraint: ${\mathbf{kd}}\ge 0$.
5:    $\mathbf{ab}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array ab must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdab}}×{\mathbf{n}}\right)$.
On entry: the Cholesky factor of $A$, as returned by nag_dpbtrf (f07hdc).
6:    $\mathbf{pdab}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix in the array ab.
Constraint: ${\mathbf{pdab}}\ge {\mathbf{kd}}+1$.
7:    $\mathbf{d}$double *Output
8:    $\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.
9:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{kd}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{kd}}\ge 0$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}>0$.
NE_INT_2
On entry, ${\mathbf{pdab}}=〈\mathit{\text{value}}〉$ and ${\mathbf{kd}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdab}}\ge {\mathbf{kd}}+1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_MAT_NOT_POS_DEF
The matrix $A$ is not positive definite.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 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

nag_det_real_band_sym (f03bhc) is not threaded in any implementation.

The time taken by nag_det_real_band_sym (f03bhc) is approximately proportional to $n$.
This function 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 (f03bhce.c)

### 10.2Program Data

Program Data (f03bhce.d)

### 10.3Program Results

Program Results (f03bhce.r)