F07 Chapter Contents
F07 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF07ADF (DGETRF)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F07ADF (DGETRF) computes the $LU$ factorization of a real $m$ by $n$ matrix.

## 2  Specification

 SUBROUTINE F07ADF ( M, N, A, LDA, IPIV, INFO)
 INTEGER M, N, LDA, IPIV(min(M,N)), INFO REAL (KIND=nag_wp) A(LDA,*)
The routine may be called by its LAPACK name dgetrf.

## 3  Description

F07ADF (DGETRF) forms the $LU$ factorization of a real $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 routine uses partial pivoting, with row interchanges.

## 4  References

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

## 5  Parameters

1:     M – INTEGERInput
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{M}}\ge 0$.
2:     N – INTEGERInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 0$.
3:     A(LDA,$*$) – REAL (KIND=nag_wp) arrayInput/Output
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.
4:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F07ADF (DGETRF) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$.
5:     IPIV($\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{M}},{\mathbf{N}}\right)$) – INTEGER arrayOutput
On exit: the pivot indices that define the permutation matrix. At the $\mathit{i}$th step, if ${\mathbf{IPIV}}\left(\mathit{i}\right)>\mathit{i}$ then row $\mathit{i}$ of the matrix $A$ was interchanged with row ${\mathbf{IPIV}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$. ${\mathbf{IPIV}}\left(i\right)\le i$ indicates that, at the $i$th step, a row interchange was not required.
6:     INFO – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, the $i$th parameter had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{INFO}}>0$
If ${\mathbf{INFO}}=i$, $U\left(i,i\right)$ 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.

## 7  Accuracy

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

The total number of floating point operations is approximately $\frac{2}{3}{n}^{3}$ if $m=n$ (the usual case), $\frac{1}{3}{n}^{2}\left(3m-n\right)$ if $m>n$ and $\frac{1}{3}{m}^{2}\left(3n-m\right)$ if $m.
A call to this routine with $m=n$ may be followed by calls to the routines:
• F07AEF (DGETRS) to solve $AX=B$ or ${A}^{\mathrm{T}}X=B$;
• F07AGF (DGECON) to estimate the condition number of $A$;
• F07AJF (DGETRI) to compute the inverse of $A$.
The complex analogue of this routine is F07ARF (ZGETRF).

## 9  Example

This example computes the $LU$ factorization of the matrix $A$, where
 $A= 1.80 2.88 2.05 -0.89 5.25 -2.95 -0.95 -3.80 1.58 -2.69 -2.90 -1.04 -1.11 -0.66 -0.59 0.80 .$