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_complex_gen (f03bn)

## Purpose

nag_det_complex_gen (f03bn) computes the determinant of a complex n$n$ by n$n$ matrix A$A$. nag_lapack_zgetrf (f07ar) must be called first to supply the matrix A$A$ in factorized form.

## Syntax

[d, id, ifail] = f03bn(a, ipiv, 'n', n)
[d, id, ifail] = nag_det_complex_gen(a, ipiv, 'n', n)

## Description

nag_det_complex_gen (f03bn) computes the determinant of a complex n$n$ by n$n$ matrix A$A$ that has been factorized by a call to nag_lapack_zgetrf (f07ar). The determinant of A$A$ is the product of the diagonal elements of U$U$ 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, : $:$) – complex 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 n$n$ by n$n$ matrix A$A$ in factorized form as returned by nag_lapack_zgetrf (f07ar).
2:     ipiv(n) – int64int32nag_int array
n, the dimension of the array, must satisfy the constraint n > 0${\mathbf{n}}>0$.
The row interchanges used to factorize matrix A$A$ as returned by nag_lapack_zgetrf (f07ar).

### 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.)
n$n$, the order of the matrix A$A$.
Constraint: n > 0${\mathbf{n}}>0$.

lda

### Output Parameters

1:     d – complex scalar
The mantissa of the real and imaginary parts of the determinant.
2:     id(2$2$) – int64int32nag_int array
The exponents for the real and imaginary parts of the determinant. The determinant, d = (dr,di)$d=\left({d}_{r},{d}_{i}\right)$, is returned as dr = Dr × 2j${d}_{r}={D}_{r}×{2}^{j}$ and di = Di × 2k${d}_{i}={D}_{i}×{2}^{k}$, where d = (Dr,Di)${\mathbf{d}}=\left({D}_{r},{D}_{i}\right)$ and j$j$ and k$k$ are stored in the first and second elements respectively of the array id on successful exit.
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: n1${\mathbf{n}}\ge 1$.
ifail = 3${\mathbf{ifail}}=3$
Constraint: ldan$\mathit{lda}\ge {\mathbf{n}}$.
ifail = 4${\mathbf{ifail}}=4$
The matrix A$A$ 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).

The time taken by nag_det_complex_gen (f03bn) is approximately proportional to n$n$.

## Example

```function nag_det_complex_gen_example
a = [1,   1+2i, 2+10i;
1+i, 3i,  -5+14i;
1+i, 5i,  -8+20i];
% LU factorisation of a
[a, ipiv, info] = nag_lapack_zgetrf(a);

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

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

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

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

Array a after factorization
1          2          3
1      1.0000     0.0000    -5.0000
1.0000     3.0000    14.0000

2      1.0000     0.0000    -3.0000
0.0000     2.0000     6.0000

3      0.5000     0.2500    -0.2500
-0.5000     0.2500    -0.2500

Pivots:
2 3 3

d =       0.06250 id = (4, 0)
Value of determinant = (  1.00000e+00,   0.00000e+00)

```
```function f03bn_example
a = [1,   1+2i, 2+10i;
1+i, 3i,  -5+14i;
1+i, 5i,  -8+20i];
% LU factorisation of a
[a, ipiv, info] = f07ar(a);

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

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

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

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

Array a after factorization
1          2          3
1      1.0000     0.0000    -5.0000
1.0000     3.0000    14.0000

2      1.0000     0.0000    -3.0000
0.0000     2.0000     6.0000

3      0.5000     0.2500    -0.2500
-0.5000     0.2500    -0.2500

Pivots:
2 3 3

d =       0.06250 id = (4, 0)
Value of determinant = (  1.00000e+00,   0.00000e+00)

```