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_sym (f03bf)

## Purpose

nag_det_real_sym (f03bf) computes the determinant of a real $n$ by $n$ symmetric positive definite matrix $A$. nag_lapack_dpotrf (f07fd) must be called first to supply the symmetric matrix $A$ in Cholesky factorized form. The storage (upper or lower triangular) used by nag_lapack_dpotrf (f07fd) is not relevant to nag_det_real_sym (f03bf) since only the diagonal elements of the factorized $A$ are referenced.

## Syntax

[d, id, ifail] = f03bf(a, 'n', n)
[d, id, ifail] = nag_det_real_sym(a, 'n', n)

## Description

nag_det_real_sym (f03bf) computes the determinant of a real $n$ by $n$ symmetric positive definite matrix $A$ that has been factorized as $A={U}^{\mathrm{T}}U$, where $U$ is upper triangular, or $A=L{L}^{\mathrm{T}}$, where $L$ is lower triangular. The determinant is the product of the squares of the diagonal elements of $U$ or $L$. The Cholesky factorized form of the matrix must be supplied; this is returned by a call to nag_lapack_dpotrf (f07fd).

## References

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{a}\left(\mathit{lda},:\right)$ – double array
The first dimension of the array a must be at least ${\mathbf{n}}$.
The second dimension of the array a must be at least ${\mathbf{n}}$.
The lower or upper triangle of the Cholesky factorized form of the $n$ by $n$ positive definite symmetric matrix $A$. Only the diagonal elements are referenced.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the first dimension of the array a.
$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{n}}>0$.
${\mathbf{ifail}}=3$
Constraint: $\mathit{lda}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=4$
The matrix $A$ is not positive definite.
${\mathbf{ifail}}=-99$
${\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 25 of Wilkinson and Reinsch (1971).

The time taken by nag_det_real_sym (f03bf) is approximately proportional to $n$.

## Example

This example computes a Cholesky factorization and calculates the determinant of the real symmetric positive definite matrix
 $6 7 6 5 7 11 8 7 6 8 11 9 5 7 9 11 .$
```function f03bf_example

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

a = [6,   7,   6,   5;
7,  11,   8,   7;
6,   8,  11,   9;
5,   7,   9,  11];
% Factorize a
[a, info] = f07fd('l', a);

fprintf('\n');
[ifail] = x04ca('l', 'n', a, 'Array a after factorization');

[d, id, ifail] = f03bf(a);

fprintf('\nd = %13.5f id = %d\n', d, id);
fprintf('Value of determinant = %13.5e\n', d*2^id);

```
```f03bf example results

Array a after factorization
1          2          3          4
1      2.4495
2      2.8577     1.6833
3      2.4495     0.5941     2.1557
4      2.0412     0.6931     1.6645     1.8927

d =       0.06909 id = 12
Value of determinant =   2.83000e+02
```