f03 Chapter Contents
f03 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_complex_lu (f03ahc)

## 1  Purpose

nag_complex_lu (f03ahc) computes an $LU$ factorization of a complex matrix, with partial pivoting, and evaluates the determinant.

## 2  Specification

 #include #include
 void nag_complex_lu (Integer n, Complex a[], Integer tda, Integer pivot[], Complex *det, Integer *dete, NagError *fail)

## 3  Description

nag_complex_lu (f03ahc) computes an $LU$ factorization of a complex matrix $A$, with partial pivoting: $PA=LU$, where $P$ is a permutation matrix, $L$ is lower triangular and $U$ is unit upper triangular. The determinant is the product of the diagonal elements of $L$ with the correct sign determined by the row interchanges.

## 4  References

Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5  Arguments

1:     nIntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 1$.
2:     a[${\mathbf{n}}×{\mathbf{tda}}$]ComplexInput/Output
Note: the $\left(i,j\right)$th element of the matrix $A$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{tda}}+j-1\right]$.
On entry: the $n$ by $n$ matrix $A$.
On exit: $A$ is overwritten by the lower triangular matrix $L$ and the off-diagonal elements of the upper triangular matrix $U$. The unit diagonal elements of $U$ are not stored.
3:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge {\mathbf{n}}$.
4:     pivot[n]IntegerOutput
On exit: ${\mathbf{pivot}}\left[i-1\right]$ gives the row index of the $i$th pivot.
5:     detComplex *Output
6:     deteInteger *Output
On exit: the determinant of $A$ is given by $\left({\mathbf{det}}\mathbf{.}\mathbf{re}+i{\mathbf{det}}\mathbf{.}\mathbf{im}\right)×{2.0}^{{\mathbf{dete}}}$. It is given in this form to avoid overflow and underflow.
7:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, ${\mathbf{tda}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. The arguments must satisfy ${\mathbf{tda}}\ge {\mathbf{n}}$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_INT_ARG_LT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_SINGULAR
The matrix $A$ is singular, possibly due to rounding errors. The factorization could not be completed. ${\mathbf{det}}\mathbf{.}\mathbf{re}$, ${\mathbf{det}}\mathbf{.}\mathbf{im}$ and dete are set to zero.

## 7  Accuracy

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

The time taken by nag_complex_lu (f03ahc) is approximately proportional to ${n}^{3}$.

## 9  Example

To compute an $LU$ factorization, with partial pivoting, and calculate the determinant, of the complex matrix
 $2 + i 1 + 2 i - 2 + 10 i 1 + i 1 + 3 i -5 + 14 i 1 + i 1 + 5 i -7 + 20 i .$

### 9.1  Program Text

Program Text (f03ahce.c)

### 9.2  Program Data

Program Data (f03ahce.d)

### 9.3  Program Results

Program Results (f03ahce.r)