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_gen (f03ba)

Purpose

nag_det_real_gen (f03ba) computes the determinant of a real nn by nn matrix AA. nag_lapack_dgetrf (f07ad) must be called first to supply the matrix AA in factorized form.

Syntax

[d, id, ifail] = f03ba(a, ipiv, 'n', n)
[d, id, ifail] = nag_det_real_gen(a, ipiv, 'n', n)

Description

nag_det_real_gen (f03ba) computes the determinant of a real nn by nn matrix AA that has been factorized by a call to nag_lapack_dgetrf (f07ad). The determinant of AA is the product of the diagonal elements of UU with the correct sign determined by the row interchanges.

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 nn
The second dimension of the array must be at least nn
The nn by nn matrix AA in factorized form as returned by nag_lapack_dgetrf (f07ad).
2:     ipiv(n) – int64int32nag_int array
n, the dimension of the array, must satisfy the constraint n > 0n>0.
The row interchanges used to factorize matrix AA as returned by nag_lapack_dgetrf (f07ad).

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a and the dimension of the array ipiv. (An error is raised if these dimensions are not equal.)
nn, the order of the matrix AA.
Constraint: n > 0n>0.

Input Parameters Omitted from the MATLAB Interface

lda

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: n1n1.
  ifail = 3ifail=3
Constraint: ldanldan.
  ifail = 4ifail=4
The matrix AA is approximately singular.

Accuracy

The accuracy of the determinant depends on the conditioning of the original matrix. For a detailed error analysis, see page 107 of Wilkinson and Reinsch (1971).

Further Comments

The time taken by nag_det_real_gen (f03ba) is approximately proportional to nn.

Example

function nag_det_real_gen_example
a = [ 33,  16,  72;
     -24, -10, -57;
      -8,  -4, -17];
% Compute LU factorisation of a
[a, ipiv, info] = nag_lapack_dgetrf(a);

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

fprintf('\nPivots:\n');
fprintf(' %d', ipiv);
fprintf('\n\n');

[d, id, ifail] = nag_det_real_gen(a, ipiv);

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

 Array a after factorization
             1          2          3
 1     33.0000    16.0000    72.0000
 2     -0.7273     1.6364    -4.6364
 3     -0.2424    -0.0741     0.1111

Pivots:
 1 2 3

d =       0.37500 id = 4
Value of determinant =   6.00000e+00

function f03ba_example
a = [ 33,  16,  72;
     -24, -10, -57;
      -8,  -4, -17];
% Compute LU factorisation of a
[a, ipiv, info] = f07ad(a);

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

fprintf('\nPivots:\n');
fprintf(' %d', ipiv);
fprintf('\n\n');

[d, id, ifail] = f03ba(a, ipiv);

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

 Array a after factorization
             1          2          3
 1     33.0000    16.0000    72.0000
 2     -0.7273     1.6364    -4.6364
 3     -0.2424    -0.0741     0.1111

Pivots:
 1 2 3

d =       0.37500 id = 4
Value of determinant =   6.00000e+00


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