# ?trtri

Computes the inverse of a triangular matrix.

## Syntax

FORTRAN 77:

call strtri( uplo, diag, n, a, lda, info )

call dtrtri( uplo, diag, n, a, lda, info )

call ctrtri( uplo, diag, n, a, lda, info )

call ztrtri( uplo, diag, n, a, lda, info )

Fortran 95:

call trtri( a [,uplo] [,diag] [,info] )

## Description

This routine computes the inverse `inv(A)` of a triangular matrix A.

## Input Parameters

uplo

  CHARACTER*1. Must be 'U' or 'L'.

  Indicates whether A is upper or lower triangular:

  If `uplo = 'U'`, then A is upper triangular.

  If `uplo = 'L'`, then A is lower triangular.

diag

  CHARACTER*1. Must be 'N' or 'U'.

  If `diag = 'N'`, then A is not a unit triangular matrix.

  If `diag = 'U'`, A is unit triangular: diagonal elements of A are assumed to be 1 and not referenced in the array a.

n

  INTEGER. The order of the matrix A; `n ≥ 0`.

a

  REAL for strtri

  DOUBLE PRECISION for dtrtri

  COMPLEX for ctrtri

  DOUBLE COMPLEX for ztrtri.

  Array: DIMENSION `(,*)`.

  Contains the matrix A.

  The second dimension of a must be at least `max(1,n)`.

lda

  INTEGER. The first dimension of a; `lda ≥ max(1, n)`.

## Output Parameters

a

  Overwritten by the n-by-n matrix `inv(A)`.

info

  INTEGER.

  If `info = 0`, the execution is successful.

  If info = -i, the i-th parameter had an illegal value.

  If `info = i`, the i-th diagonal element of A is zero, A is singular, and the inversion could not be completed.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their Fortran 77 counterparts. For general conventions applied to skip redundant or reconstructible arguments, see Fortran 95 Interface Conventions.

Specific details for the routine trtri interface are as follows:

a

  Holds the matrix A of size (`n,n`).

uplo

  Must be 'U' or 'L'. The default value is 'U'.

diag

  Must be 'N' or 'U'. The default value is 'N'.

## Application Notes

The computed inverse X satisfies the following error bounds:
`|XA - I| ≤ c(n)ε |X||A|`
`|XA - I| ≤ c(n)ε |A-1||A||X|,`

where `c(n)` is a modest linear function of n; ε is the machine precision; I denotes the identity matrix.

The total number of floating-point operations is approximately `(1/3)n3` for real flavors and `(4/3)n3` for complex flavors.

Parent topic: Routines for Matrix Inversion