# p?getri

Computes the inverse of a LU-factored distributed matrix.

## Syntax

call psgetri(n, a, ia, ja, desca, ipiv, work, lwork, iwork, liwork, info)

call pdgetri(n, a, ia, ja, desca, ipiv, work, lwork, iwork, liwork, info)

call pcgetri(n, a, ia, ja, desca, ipiv, work, lwork, iwork, liwork, info)

call pzgetri(n, a, ia, ja, desca, ipiv, work, lwork, iwork, liwork, info)

## Description

This routine computes the inverse of a general distributed matrix `sub(A) = A(ia:ia+n-1, ja:ja+n-1)` using the LU factorization computed by p?getrf. This method inverts U and then computes the inverse of `sub(A)` by solving the system

`inv(sub(A))*L = inv(U)`

for `inv(sub(A)`.

## Input Parameters

n

  (global) INTEGER. The number of rows and columns to be operated on, that is, the order of the distributed submatrix sub(A) `(n≥0)`.

a

  (local)

  REAL for psgetri

  DOUBLE PRECISION for pdgetri

  COMPLEX for pcgetri

  DOUBLE COMPLEX for pzgetri.

  Pointer into the local memory to an array of local dimension `a(lld_a,LOCc(ja+n-1))`.

  On entry, the array a contains the local pieces of the L and U obtained by the factorization `sub(A) = P*L*U` computed by p?getrf.

ia, ja

  (global) INTEGER. The row and column indices in the global array A indicating the first row and the first column of the submatrix sub(A), respectively.

desca

  (global and local) INTEGER array, dimension (dlen_). The array descriptor for the distributed matrix A.

work

  (local)

  REAL for psgetri

  DOUBLE PRECISION for pdgetri

  COMPLEX for pcgetri

  DOUBLE COMPLEX for pzgetri.

  The array work of dimension (lwork) is a workspace array.

lwork

  (local) INTEGER. The dimension of the array work. lwork must be at least

  `lwork≥LOCr(n+mod(ia-1,mb_a))*nb_a`.

  The array work is used to keep at most an entire column block of sub(A).

iwork

  (local) INTEGER. Workspace array used for physically transposing the pivots, DIMENSION (liwork).

liwork

  (local or global) INTEGER. The dimension of the array iwork.

  The minimal value liwork of is determined by the following code:
  `if NPROW == NPCOL then`
  `liwork = LOCc(n_a + mod(ja-1,nb_a))+ nb_a`
  `else`
  `liwork = LOCc(n_a + mod(ja-1,nb_a)) +`
  `max(ceil(ceil(LOCr(m_a)/mb_a)/(lcm/NPROW)),nb_a)`
  `end if`

  where lcm is the least common multiple of process rows and columns (NPROW and NPCOL).

## Output Parameters

ipiv

  (local) INTEGER.

  Array, dimension `(LOCr(m_a)+ mb_a)`.

  This array contains the pivoting information.

  If `ipiv(i)=j`, then the local row i was swapped with the global row j.

  This array is tied to the distributed matrix A.

`work(1)`

  On exit, `work(1)` contains the minimum value of lwork required for optimum performance.

`iwork(1)`

  On exit, `iwork(1)` contains the minimum value of liwork required for optimum performance.

info

  (global) INTEGER. If `info=0`, the execution is successful.

  info < 0:

  If the i-th argument is an array and the j-th entry had an illegal value, then `info = -(i*100+j)`; if the i-th argument is a scalar and had an illegal value, then `info = -i`.

  `info > 0`:

  If info = i, U(i,i) 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.

Parent topic: Routines for Matrix Inversion