# NAG FL Interfacef07ajf (dgetri)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f07ajf computes the inverse of a real matrix $A$, where $A$ has been factorized by f07adf.

## 2Specification

Fortran Interface
 Subroutine f07ajf ( n, a, lda, ipiv, work, info)
 Integer, Intent (In) :: n, lda, ipiv(*), lwork Integer, Intent (Out) :: info Real (Kind=nag_wp), Intent (Inout) :: a(lda,*) Real (Kind=nag_wp), Intent (Out) :: work(max(1,lwork))
#include <nag.h>
 void f07ajf_ (const Integer *n, double a[], const Integer *lda, const Integer ipiv[], double work[], const Integer *lwork, Integer *info)
The routine may be called by the names f07ajf, nagf_lapacklin_dgetri or its LAPACK name dgetri.

## 3Description

f07ajf is used to compute the inverse of a real matrix $A$, the routine must be preceded by a call to f07adf, which computes the $LU$ factorization of $A$ as $A=PLU$. The inverse of $A$ is computed by forming ${U}^{-1}$ and then solving the equation $XPL={U}^{-1}$ for $X$.
Du Croz J J and Higham N J (1992) Stability of methods for matrix inversion IMA J. Numer. Anal. 12 1–19

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
2: $\mathbf{a}\left({\mathbf{lda}},*\right)$Real (Kind=nag_wp) array Input/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 $LU$ factorization of $A$, as returned by f07adf.
On exit: the factorization is overwritten by the $n×n$ matrix ${A}^{-1}$.
3: $\mathbf{lda}$Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f07ajf is called.
Constraint: ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
4: $\mathbf{ipiv}\left(*\right)$Integer array Input
Note: the dimension of the array ipiv must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the pivot indices, as returned by f07adf.
5: $\mathbf{work}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{lwork}}\right)\right)$Real (Kind=nag_wp) array Workspace
On exit: if ${\mathbf{info}}=0$, ${\mathbf{work}}\left(1\right)$ contains the minimum value of lwork required for optimum performance.
6: $\mathbf{lwork}$Integer Input
On entry: the dimension of the array work as declared in the (sub)program from which f07ajf is called, unless ${\mathbf{lwork}}=-1$, in which case a workspace query is assumed and the routine only calculates the optimal dimension of work (using the formula given below).
Suggested value: for optimum performance lwork should be at least ${\mathbf{n}}×\mathit{nb}$, where $\mathit{nb}$ is the block size.
Constraint: ${\mathbf{lwork}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ or ${\mathbf{lwork}}=-1$.
7: $\mathbf{info}$Integer Output
On exit: ${\mathbf{info}}=0$ unless the routine detects an error (see Section 6).

## 6Error Indicators and Warnings

${\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 zero. $U$ is singular, and the inverse of $A$ cannot be computed.

## 7Accuracy

The computed inverse $X$ satisfies a bound of the form:
 $|XA-I|≤c(n)ε|X|P|L||U| ,$
where $c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision.
Note that a similar bound for $|AX-I|$ cannot be guaranteed, although it is almost always satisfied. See Du Croz and Higham (1992).

## 8Parallelism and Performance

f07ajf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The total number of floating-point operations is approximately $\frac{4}{3}{n}^{3}$.
The complex analogue of this routine is f07awf.

## 10Example

This example computes the inverse 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 ) .$
Here $A$ is nonsymmetric and must first be factorized by f07adf.

### 10.1Program Text

Program Text (f07ajfe.f90)

### 10.2Program Data

Program Data (f07ajfe.d)

### 10.3Program Results

Program Results (f07ajfe.r)