f07ar computes the $LU$ factorization of a complex $m$ by $n$ matrix.

# Syntax

C#
```public static void f07ar(
int m,
int n,
Complex[,] a,
int[] ipiv,
out int info
)```
Visual Basic
```Public Shared Sub f07ar ( _
m As Integer, _
n As Integer, _
a As Complex(,), _
ipiv As Integer(), _
<OutAttribute> ByRef info As Integer _
)```
Visual C++
```public:
static void f07ar(
int m,
int n,
array<Complex,2>^ a,
array<int>^ ipiv,
[OutAttribute] int% info
)```
F#
```static member f07ar :
m : int *
n : int *
a : Complex[,] *
ipiv : int[] *
info : int byref -> unit
```

#### Parameters

m
Type: System..::..Int32
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
n
Type: System..::..Int32
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
a
Type: array<NagLibrary..::..Complex,2>[,](,)[,][,]
An array of size [dim1, dim2]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
Note: the second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the $m$ by $n$ matrix $A$.
On exit: the factors $L$ and $U$ from the factorization $A=PLU$; the unit diagonal elements of $L$ are not stored.
ipiv
Type: array<System..::..Int32>[]()[][]
An array of size [$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)$]
On exit: the pivot indices that define the permutation matrix. At the $\mathit{i}$th step, if ${\mathbf{ipiv}}\left[\mathit{i}-1\right]>\mathit{i}$ then row $\mathit{i}$ of the matrix $A$ was interchanged with row ${\mathbf{ipiv}}\left[\mathit{i}-1\right]$, for $\mathit{i}=1,2,\dots ,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$. ${\mathbf{ipiv}}\left[i-1\right]\le i$ indicates that, at the $i$th step, a row interchange was not required.
info
Type: System..::..Int32%
On exit: ${\mathbf{info}}=0$ unless the method detects an error (see [Error Indicators and Warnings]).

# Description

f07ar forms the $LU$ factorization of a complex $m$ by $n$ matrix $A$ as $A=PLU$, where $P$ is a permutation matrix, $L$ is lower triangular with unit diagonal elements (lower trapezoidal if $m>n$) and $U$ is upper triangular (upper trapezoidal if $m). Usually $A$ is square $\left(m=n\right)$, and both $L$ and $U$ are triangular. The method uses partial pivoting, with row interchanges.

# References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

# Error Indicators and Warnings

Some error messages may refer to parameters that are dropped from this interface (LDA) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{info}}<0$
If ${\mathbf{info}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{info}}>0$
Element $〈\mathit{\text{value}}〉$ of the diagonal is exactly zero. The factorization has been completed, but the factor $U$ is exactly singular, and division by zero will occur if it is used to solve a system of equations.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-4000$
Invalid dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# Accuracy

The computed factors $L$ and $U$ are the exact factors of a perturbed matrix $A+E$, where
 $E≤cminm,nεPLU,$
$c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision.

# Parallelism and Performance

None.

The total number of real floating-point operations is approximately $\frac{8}{3}{n}^{3}$ if $m=n$ (the usual case), $\frac{4}{3}{n}^{2}\left(3m-n\right)$ if $m>n$ and $\frac{4}{3}{m}^{2}\left(3n-m\right)$ if $m.
A call to this method with $m=n$ may be followed by calls to the methods:
• f07as to solve $AX=B$, ${A}^{\mathrm{T}}X=B$ or ${A}^{\mathrm{H}}X=B$;
• (F07AUF not in this release) to estimate the condition number of $A$;
• (F07AWF not in this release) to compute the inverse of $A$.
The real analogue of this method is (F07ADF not in this release).

# Example

This example computes the $LU$ factorization of the matrix $A$, where
 $A= -1.34+2.55i 0.28+3.17i -6.39-2.20i 0.72-0.92i -0.17-1.41i 3.31-0.15i -0.15+1.34i 1.29+1.38i -3.29-2.39i -1.91+4.42i -0.14-1.35i 1.72+1.35i 2.41+0.39i -0.56+1.47i -0.83-0.69i -1.96+0.67i .$

Example program (C#): f07are.cs

Example program data: f07are.d

Example program results: f07are.r