hide long namesshow long names
hide short namesshow short names
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 nn by nn symmetric positive definite banded matrix AA 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 AA is calculated using the Cholesky factorization A = UTUA=UTU, where UU is an upper triangular band matrix, or A = LLTA=LLT, where LL is a lower triangular band matrix. The determinant of AA is the product of the squares of the diagonal elements of UU or LL.

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 AA was stored and how it was factorized. This should not be altered following a call to nag_lapack_dpbtrf (f07hd).
uplo = 'U'uplo='U'
The upper triangular part of AA was originally stored and AA was factorized as UTUUTU where UU is upper triangular.
uplo = 'L'uplo='L'
The lower triangular part of AA was originally stored and AA was factorized as LLTLLT where LL is lower triangular.
Constraint: uplo = 'U'uplo='U' or 'L''L'.
2:     kd – int64int32nag_int scalar
kdkd, the number of superdiagonals or subdiagonals of the matrix AA.
Constraint: kd0kd0.
3:     ab(ldab, : :) – double array
The first dimension of the array ab must be at least kd + 1kd+1
The second dimension of the array must be at least max (1,n)max(1,n)
The Cholesky factor of AA, as returned by nag_lapack_dpbtrf (f07hd).

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The second dimension of the array ab.
nn, the order of the matrix AA.
Constraint: n > 0n>0.

Input Parameters Omitted from the MATLAB Interface

ldab

Output Parameters

1:     d – double scalar
2:     id – int64int32nag_int scalar
The determinant of AA is given by d × 2.0idd×2.0id. It is given in this form to avoid overflow or underflow.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
Constraint: uplo = 'L'uplo='L' or 'U''U'.
  ifail = 2ifail=2
Constraint: n > 0n>0.
  ifail = 3ifail=3
Constraint: kd0kd0.
  ifail = 5ifail=5
Constraint: ldabkd + 1ldabkd+1.
  ifail = 6ifail=6
The matrix AA 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).

Further Comments

The time taken by nag_det_real_band_sym (f03bh) is approximately proportional to nn.
This function should only be used when mnmn since as mm approaches nn, 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


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–2013