F07 Chapter Contents
F07 Chapter Introduction
NAG Library Manual

NAG Library Routine DocumentF07AWF (ZGETRI)

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

F07AWF (ZGETRI) computes the inverse of a complex matrix $A$, where $A$ has been factorized by F07ARF (ZGETRF).

2  Specification

 SUBROUTINE F07AWF ( N, A, LDA, IPIV, WORK, LWORK, INFO)
 INTEGER N, LDA, IPIV(*), LWORK, INFO COMPLEX (KIND=nag_wp) A(LDA,*), WORK(max(1,LWORK))
The routine may be called by its LAPACK name zgetri.

3  Description

F07AWF (ZGETRI) is used to compute the inverse of a complex matrix $A$, the routine must be preceded by a call to F07ARF (ZGETRF), 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$.

4  References

Du Croz J J and Higham N J (1992) Stability of methods for matrix inversion IMA J. Numer. Anal. 12 1–19

5  Parameters

1:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 0$.
2:     $\mathrm{A}\left({\mathbf{LDA}},*\right)$ – COMPLEX (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 $LU$ factorization of $A$, as returned by F07ARF (ZGETRF).
On exit: the factorization is overwritten by the $n$ by $n$ matrix ${A}^{-1}$.
3:     $\mathrm{LDA}$ – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F07AWF (ZGETRI) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
4:     $\mathrm{IPIV}\left(*\right)$ – INTEGER arrayInput
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 F07ARF (ZGETRF).
5:     $\mathrm{WORK}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)\right)$ – COMPLEX (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}=0$, ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimum performance.
6:     $\mathrm{LWORK}$ – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F07AWF (ZGETRI) 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:     $\mathrm{INFO}$ – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

6  Error 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.

7  Accuracy

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

8  Parallelism and Performance

F07AWF (ZGETRI) is not threaded by NAG in any implementation.
F07AWF (ZGETRI) 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 real floating-point operations is approximately $\frac{16}{3}{n}^{3}$.
The real analogue of this routine is F07AJF (DGETRI).

10  Example

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

10.1  Program Text

Program Text (f07awfe.f90)

10.2  Program Data

Program Data (f07awfe.d)

10.3  Program Results

Program Results (f07awfe.r)