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$n$ by n$n$ symmetric positive definite matrix A$A$. nag_lapack_dpotrf (f07fd) must be called first to supply the symmetric matrix A$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$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$n$ by n$n$ symmetric positive definite matrix A$A$ that has been factorized as A = UTU$A={U}^{\mathrm{T}}U$, where U$U$ is upper triangular, or A = LLT$A=L{L}^{\mathrm{T}}$, where L$L$ is lower triangular. The determinant is the product of the squares of the diagonal elements of U$U$ or L$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:     a(lda, : $:$) – double array
The first dimension of the array a must be at least n${\mathbf{n}}$
The second dimension of the array must be at least n${\mathbf{n}}$
The lower or upper triangle of the Cholesky factorized form of the n$n$ by n$n$ positive definite symmetric matrix A$A$. Only the diagonal elements are referenced.

### Optional Input Parameters

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

lda

### 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: n > 0${\mathbf{n}}>0$.
ifail = 3${\mathbf{ifail}}=3$
Constraint: ldan$\mathit{lda}\ge {\mathbf{n}}$.
ifail = 4${\mathbf{ifail}}=4$
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 25 of Wilkinson and Reinsch (1971).

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

## Example

```function nag_det_real_sym_example
a = [6,   7,   6,   5;
7,  11,   8,   7;
6,   8,  11,   9;
5,   7,   9,  11];
% Factorize a
[a, info] = nag_lapack_dpotrf('l', a);

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

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

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

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

```
```function f03bf_example
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);
```
```

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

```