Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_det_real_band_sym (f03bh)

## Purpose

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

## Syntax

[d, id, ifail] = f03bh(uplo, kd, ab, 'n', n)
[d, id, ifail] = nag_det_real_band_sym(uplo, kd, ab, 'n', n)

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

## References

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{uplo}$ – string (length ≥ 1)
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_lapack_dpbtrf (f07hd).
${\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:     $\mathrm{kd}$int64int32nag_int scalar
${k}_{d}$, the number of superdiagonals or subdiagonals of the matrix $A$.
Constraint: ${\mathbf{kd}}\ge 0$.
3:     $\mathrm{ab}\left(\mathit{ldab},:\right)$ – double array
The first dimension of the array ab must be at least ${\mathbf{kd}}+1$.
The second dimension of the array ab must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The Cholesky factor of $A$, as returned by nag_lapack_dpbtrf (f07hd).

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the second dimension of the array ab.
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}>0$.

### Output Parameters

1:     $\mathrm{d}$ – double scalar
2:     $\mathrm{id}$int64int32nag_int scalar
The determinant of $A$ is given by ${\mathbf{d}}×{2.0}^{{\mathbf{id}}}$. It is given in this form to avoid overflow or underflow.
3:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
Constraint: ${\mathbf{uplo}}=\text{'L'}$ or $\text{'U'}$.
${\mathbf{ifail}}=2$
Constraint: ${\mathbf{n}}>0$.
${\mathbf{ifail}}=3$
Constraint: ${\mathbf{kd}}\ge 0$.
${\mathbf{ifail}}=5$
Constraint: $\mathit{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.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## 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 nag_det_real_band_sym (f03bh) 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.

## 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 .$
```function f03bh_example

fprintf('f03bh example results\n\n');

uplo = 'l';
kd   = int64(2);
n    = int64(7);
ab = [ 5,  6,  6,  6,  6,  6,  5;
-4, -4, -4, -4, -4, -4,  0;
1,  1,  1,  1,  1,  0,  0];
% Factorize a
[ab, info] = f07hd(uplo, kd, ab);

if info == 0
fprintf('\n');
[ifail] = x04ce(n, n, kd, int64(0), ab, 'Array ab after factorization');

[d, id, ifail] = f03bh(uplo, kd, ab);

fprintf('d = %13.5f id = %d\n', d, id);
fprintf('Value of determinant = %13.5e\n', d*2^id);
else
fprintf('\n** Factorization routine returned error flag info = %d\n', info);
end

```
```f03bh example results

Array ab after factorization
1          2          3          4          5          6          7
1      2.2361
2     -1.7889     1.6733
3      0.4472    -1.9124     1.4639
4                 0.5976    -1.9518     1.3540
5                            0.6831    -1.9695     1.2863
6                                       0.7385    -1.9789     1.2403
7                                                  0.7774    -1.9846     0.6761
d =       0.25000 id = 8
Value of determinant =   6.40000e+01
```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015