nag_det_real_gen (f03bac) (PDF version)
f03 Chapter Contents
f03 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_det_real_gen (f03bac)

## 1  Purpose

nag_det_real_gen (f03bac) computes the determinant of a real $n$ by $n$ matrix $A$. nag_dgetrf (f07adc) must be called first to supply the matrix $A$ in factorized form.

## 2  Specification

 #include #include
 void nag_det_real_gen (Nag_OrderType order, Integer n, const double a[], Integer pda, const Integer ipiv[], double *d, Integer *id, NagError *fail)

## 3  Description

nag_det_real_gen (f03bac) computes the determinant of a real $n$ by $n$ matrix $A$ that has been factorized by a call to nag_dgetrf (f07adc). The determinant of $A$ is the product of the diagonal elements of $U$ with the correct sign determined by the row interchanges.
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5  Arguments

1:    $\mathbf{order}$Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 2.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}>0$.
3:    $\mathbf{a}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array a must be at least ${\mathbf{pda}}×{\mathbf{n}}$.
The $\left(i,j\right)$th element of the factorized form of the matrix $A$ is stored in
• ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n$ by $n$ matrix $A$ in factorized form as returned by nag_dgetrf (f07adc).
4:    $\mathbf{pda}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraint: ${\mathbf{pda}}\ge {\mathbf{n}}$.
5:    $\mathbf{ipiv}\left[{\mathbf{n}}\right]$const IntegerInput
On entry: the row interchanges used to factorize matrix $A$ as returned by nag_dgetrf (f07adc).
6:    $\mathbf{d}$double *Output
7:    $\mathbf{id}$Integer *Output
On exit: the determinant of $A$ is given by ${\mathbf{d}}×{2.0}^{{\mathbf{id}}}$. It is given in this form to avoid overflow or underflow.
8:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_INT_2
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}\ge {\mathbf{n}}$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_SINGULAR
The matrix $A$ is approximately singular.

## 7  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).

## 8  Parallelism and Performance

nag_det_real_gen (f03bac) is not threaded in any implementation.

## 9  Further Comments

The time taken by nag_det_real_gen (f03bac) is approximately proportional to $n$.

## 10  Example

This example computes the $LU$ factorization with partial pivoting, and calculates the determinant, of the real matrix
 $33 16 72 -24 -10 -57 -8 -4 -17 .$

### 10.1  Program Text

Program Text (f03bace.c)

### 10.2  Program Data

Program Data (f03bace.d)

### 10.3  Program Results

Program Results (f03bace.r)

nag_det_real_gen (f03bac) (PDF version)
f03 Chapter Contents
f03 Chapter Introduction
NAG Library Manual