Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_dpotri (f07fj)

## Purpose

nag_lapack_dpotri (f07fj) computes the inverse of a real symmetric positive definite matrix A$A$, where A$A$ has been factorized by nag_lapack_dpotrf (f07fd).

## Syntax

[a, info] = f07fj(uplo, a, 'n', n)
[a, info] = nag_lapack_dpotri(uplo, a, 'n', n)

## Description

nag_lapack_dpotri (f07fj) is used to compute the inverse of a real symmetric positive definite matrix A$A$, the function must be preceded by a call to nag_lapack_dpotrf (f07fd), which computes the Cholesky factorization of A$A$.
If uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, A = UTU$A={U}^{\mathrm{T}}U$ and A1${A}^{-1}$ is computed by first inverting U$U$ and then forming (U1)UT$\left({U}^{-1}\right){U}^{-\mathrm{T}}$.
If uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, A = LLT$A=L{L}^{\mathrm{T}}$ and A1${A}^{-1}$ is computed by first inverting L$L$ and then forming LT(L1)${L}^{-\mathrm{T}}\left({L}^{-1}\right)$.

## References

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

## Parameters

### Compulsory Input Parameters

1:     uplo – string (length ≥ 1)
Specifies how A$A$ has been factorized.
uplo = 'U'${\mathbf{uplo}}=\text{'U'}$
A = UTU$A={U}^{\mathrm{T}}U$, where U$U$ is upper triangular.
uplo = 'L'${\mathbf{uplo}}=\text{'L'}$
A = LLT$A=L{L}^{\mathrm{T}}$, where L$L$ is lower triangular.
Constraint: uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or 'L'$\text{'L'}$.
2:     a(lda, : $:$) – double array
The first dimension of the array a must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The upper triangular matrix U$U$ if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or the lower triangular matrix L$L$ if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, as returned by nag_lapack_dpotrf (f07fd).

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a The second dimension of the array a.
n$n$, the order of the matrix A$A$.
Constraint: n0${\mathbf{n}}\ge 0$.

lda

### Output Parameters

1:     a(lda, : $:$) – double array
The first dimension of the array a will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
ldamax (1,n)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
U$U$ stores the upper triangle of A1${A}^{-1}$ if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$; L$L$ stores the lower triangle of A1${A}^{-1}$ if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$.
2:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: uplo, 2: n, 3: a, 4: lda, 5: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
W INFO > 0${\mathbf{INFO}}>0$
If info = i${\mathbf{info}}=i$, the i$i$th diagonal element of the Cholesky factor is zero; the Cholesky factor is singular and the inverse of A$A$ cannot be computed.

## Accuracy

The computed inverse X$X$ satisfies
 ‖XA − I‖2 ≤ c(n)εκ2(A)   and   ‖AX − I‖2 ≤ c(n)εκ2(A) , $‖XA-I‖2≤c(n)εκ2(A) and ‖AX-I‖2≤c(n)εκ2(A) ,$
where c(n)$c\left(n\right)$ is a modest function of n$n$, ε$\epsilon$ is the machine precision and κ2(A)${\kappa }_{2}\left(A\right)$ is the condition number of A$A$ defined by
 κ2(A) = ‖A‖2‖A − 1‖2 . $κ2(A)=‖A‖2‖A-1‖2 .$

The total number of floating point operations is approximately (2/3)n3$\frac{2}{3}{n}^{3}$.
The complex analogue of this function is nag_lapack_zpotri (f07fw).

## Example

```function nag_lapack_dpotri_example
uplo = 'L';
a = [2.039607805437114, 0, 0, 0;
-1.529705854077835, 1.640121946685673, 0, 0;
0.2745625891934577, -0.2499814119483738, 0.7887488055748053, 0;
-0.04902903378454601, 0.6737303907389101, 0.6616575633742563, 0.5346894269298688];
[aOut, info] = nag_lapack_dpotri(uplo, a)
```
```

aOut =

0.6995         0         0         0
0.7769    1.4239         0         0
0.7508    1.8255    4.0688         0
-0.9340   -1.8841   -2.9342    3.4978

info =

0

```
```function f07fj_example
uplo = 'L';
a = [2.039607805437114, 0, 0, 0;
-1.529705854077835, 1.640121946685673, 0, 0;
0.2745625891934577, -0.2499814119483738, 0.7887488055748053, 0;
-0.04902903378454601, 0.6737303907389101, 0.6616575633742563, 0.5346894269298688];
[aOut, info] = f07fj(uplo, a)
```
```

aOut =

0.6995         0         0         0
0.7769    1.4239         0         0
0.7508    1.8255    4.0688         0
-0.9340   -1.8841   -2.9342    3.4978

info =

0

```

Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013