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_dsptri (f07pj)

## Purpose

nag_lapack_dsptri (f07pj) computes the inverse of a real symmetric indefinite matrix $A$, where $A$ has been factorized by nag_lapack_dsptrf (f07pd), using packed storage.

## Syntax

[ap, info] = f07pj(uplo, ap, ipiv, 'n', n)
[ap, info] = nag_lapack_dsptri(uplo, ap, ipiv, 'n', n)

## Description

nag_lapack_dsptri (f07pj) is used to compute the inverse of a real symmetric indefinite matrix $A$, the function must be preceded by a call to nag_lapack_dsptrf (f07pd), which computes the Bunch–Kaufman factorization of $A$, using packed storage.
If ${\mathbf{uplo}}=\text{'U'}$, $A=PUD{U}^{\mathrm{T}}{P}^{\mathrm{T}}$ and ${A}^{-1}$ is computed by solving ${U}^{\mathrm{T}}{P}^{\mathrm{T}}XPU={D}^{-1}$.
If ${\mathbf{uplo}}=\text{'L'}$, $A=PLD{L}^{\mathrm{T}}{P}^{\mathrm{T}}$ and ${A}^{-1}$ is computed by solving ${L}^{\mathrm{T}}{P}^{\mathrm{T}}XPL={D}^{-1}$.

## 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:     $\mathrm{uplo}$ – string (length ≥ 1)
Specifies how $A$ has been factorized.
${\mathbf{uplo}}=\text{'U'}$
$A=PUD{U}^{\mathrm{T}}{P}^{\mathrm{T}}$, where $U$ is upper triangular.
${\mathbf{uplo}}=\text{'L'}$
$A=PLD{L}^{\mathrm{T}}{P}^{\mathrm{T}}$, where $L$ is lower triangular.
Constraint: ${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.
2:     $\mathrm{ap}\left(:\right)$ – double array
The dimension of the array ap must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×\left({\mathbf{n}}+1\right)/2\right)$
The factorization of $A$ stored in packed form, as returned by nag_lapack_dsptrf (f07pd).
3:     $\mathrm{ipiv}\left(:\right)$int64int32nag_int array
The dimension of the array ipiv must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
Details of the interchanges and the block structure of $D$, as returned by nag_lapack_dsptrf (f07pd).

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the dimension of the array ipiv.
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{ap}\left(:\right)$ – double array
The dimension of the array ap will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×\left({\mathbf{n}}+1\right)/2\right)$
The factorization stores the $n$ by $n$ matrix ${A}^{-1}$.
More precisely,
• if ${\mathbf{uplo}}=\text{'U'}$, the upper triangle of ${A}^{-1}$ must be stored with element ${A}_{ij}$ in ${\mathbf{ap}}\left(i+j\left(j-1\right)/2\right)$ for $i\le j$;
• if ${\mathbf{uplo}}=\text{'L'}$, the lower triangle of ${A}^{-1}$ must be stored with element ${A}_{ij}$ in ${\mathbf{ap}}\left(i+\left(2n-j\right)\left(j-1\right)/2\right)$ for $i\ge j$.
2:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see 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.

${\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.
W  ${\mathbf{info}}>0$
Element $_$ of the diagonal is exactly zero. $D$ is singular and the inverse of $A$ cannot be computed.

## Accuracy

The computed inverse $X$ satisfies a bound of the form
• if ${\mathbf{uplo}}=\text{'U'}$, $\left|D{U}^{\mathrm{T}}{P}^{\mathrm{T}}XPU-I\right|\le c\left(n\right)\epsilon \left(\left|D\right|\left|{U}^{\mathrm{T}}\right|{P}^{\mathrm{T}}\left|X\right|P\left|U\right|+\left|D\right|\left|{D}^{-1}\right|\right)$;
• if ${\mathbf{uplo}}=\text{'L'}$, $\left|D{L}^{\mathrm{T}}{P}^{\mathrm{T}}XPL-I\right|\le c\left(n\right)\epsilon \left(\left|D\right|\left|{L}^{\mathrm{T}}\right|{P}^{\mathrm{T}}\left|X\right|P\left|L\right|+\left|D\right|\left|{D}^{-1}\right|\right)$,
$c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision

The total number of floating-point operations is approximately $\frac{2}{3}{n}^{3}$.
The complex analogues of this function are nag_lapack_zhptri (f07pw) for Hermitian matrices and nag_lapack_zsptri (f07qw) for symmetric matrices.

## Example

This example computes the inverse of the matrix $A$, where
 $A= 2.07 3.87 4.20 -1.15 3.87 -0.21 1.87 0.63 4.20 1.87 1.15 2.06 -1.15 0.63 2.06 -1.81 .$
Here $A$ is symmetric indefinite, stored in packed form, and must first be factorized by nag_lapack_dsptrf (f07pd).
```function f07pj_example

fprintf('f07pj example results\n\n');

% Indefinite matrix A (lower triangular part stored in packed format)
uplo = 'L';
n = int64(4);
ap = [2.07;   3.87;   4.20;   -1.15;
-0.21;   1.87;    0.63;
1.15;    2.06;
-1.81];

% Factorize
[apf, ipiv, info] = f07pd( ...
uplo, n, ap);

% Invert
[ainv, info] = f07pj( ...
uplo, apf, ipiv);

[ifail] = x04cc( ...
uplo, 'Non-unit', n, ainv, 'Inverse');

```
```f07pj example results

Inverse
1          2          3          4
1      0.7485
2      0.5221    -0.1605
3     -1.0058    -0.3131     1.3501
4     -1.4386    -0.7440     2.0667     2.4547
```