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

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$n$ by n$n$ symmetric positive definite banded matrix A$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$A$ is calculated using the Cholesky factorization A = UTU$A={U}^{\mathrm{T}}U$, where U$U$ is an upper triangular band matrix, or A = LLT$A=L{L}^{\mathrm{T}}$, where L$L$ is a lower triangular band matrix. The determinant of A$A$ is the product of the squares of the diagonal elements of U$U$ or L$L$.

References

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

Parameters

Compulsory Input Parameters

1:     uplo – string (length ≥ 1)
Indicates whether the upper or lower triangular part of A$A$ was stored and how it was factorized. This should not be altered following a call to nag_lapack_dpbtrf (f07hd).
uplo = 'U'${\mathbf{uplo}}=\text{'U'}$
The upper triangular part of A$A$ was originally stored and A$A$ was factorized as UTU${U}^{\mathrm{T}}U$ where U$U$ is upper triangular.
uplo = 'L'${\mathbf{uplo}}=\text{'L'}$
The lower triangular part of A$A$ was originally stored and A$A$ was factorized as LLT$L{L}^{\mathrm{T}}$ where L$L$ is lower triangular.
Constraint: uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or 'L'$\text{'L'}$.
2:     kd – int64int32nag_int scalar
kd${k}_{d}$, the number of superdiagonals or subdiagonals of the matrix A$A$.
Constraint: kd0${\mathbf{kd}}\ge 0$.
3:     ab(ldab, : $:$) – double array
The first dimension of the array ab must be at least kd + 1${\mathbf{kd}}+1$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The Cholesky factor of A$A$, as returned by nag_lapack_dpbtrf (f07hd).

Optional Input Parameters

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

ldab

Output Parameters

1:     d – double scalar
2:     id – int64int32nag_int scalar
The determinant of A$A$ is given by d × 2.0id${\mathbf{d}}×{2.0}^{{\mathbf{id}}}$. It is given in this form to avoid overflow or underflow.
3:     ifail – int64int32nag_int scalar
${\mathrm{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:
ifail = 1${\mathbf{ifail}}=1$
Constraint: uplo = 'L'${\mathbf{uplo}}=\text{'L'}$ or 'U'$\text{'U'}$.
ifail = 2${\mathbf{ifail}}=2$
Constraint: n > 0${\mathbf{n}}>0$.
ifail = 3${\mathbf{ifail}}=3$
Constraint: kd0${\mathbf{kd}}\ge 0$.
ifail = 5${\mathbf{ifail}}=5$
Constraint: ldabkd + 1$\mathit{ldab}\ge {\mathbf{kd}}+1$.
ifail = 6${\mathbf{ifail}}=6$
The matrix A$A$ is not positive definite.

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$n$.
This function should only be used when mn$m\ll n$ since as m$m$ approaches n$n$, it becomes less efficient to take advantage of the band form.

Example

```function nag_det_real_band_sym_example
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] = nag_lapack_dpbtrf(uplo, kd, ab);

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

[d, id, ifail] = nag_det_real_band_sym(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
```
```

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

```
```function f03bh_example
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
```
```

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

```