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_dsptrd (f08ge)

## Purpose

nag_lapack_dsptrd (f08ge) reduces a real symmetric matrix to tridiagonal form, using packed storage.

## Syntax

[ap, d, e, tau, info] = f08ge(uplo, n, ap)
[ap, d, e, tau, info] = nag_lapack_dsptrd(uplo, n, ap)

## Description

nag_lapack_dsptrd (f08ge) reduces a real symmetric matrix A$A$, held in packed storage, to symmetric tridiagonal form T$T$ by an orthogonal similarity transformation: A = QTQT$A=QT{Q}^{\mathrm{T}}$.
The matrix Q$Q$ is not formed explicitly but is represented as a product of n1$n-1$ elementary reflectors (see the F08 Chapter Introduction for details). Functions are provided to work with Q$Q$ in this representation (see Section [Further Comments]).

## References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## Parameters

### Compulsory Input Parameters

1:     uplo – string (length ≥ 1)
Indicates whether the upper or lower triangular part of A$A$ is stored.
uplo = 'U'${\mathbf{uplo}}=\text{'U'}$
The upper triangular part of A$A$ is stored.
uplo = 'L'${\mathbf{uplo}}=\text{'L'}$
The lower triangular part of A$A$ is stored.
Constraint: uplo = 'U'${\mathbf{uplo}}=\text{'U'}$ or 'L'$\text{'L'}$.
2:     n – int64int32nag_int scalar
n$n$, the order of the matrix A$A$.
Constraint: n0${\mathbf{n}}\ge 0$.
3:     ap( : $:$) – double array
Note: the dimension of the array ap must be at least max (1,n × (n + 1) / 2)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×\left({\mathbf{n}}+1\right)/2\right)$.
The upper or lower triangle of the n$n$ by n$n$ symmetric matrix A$A$, packed by columns.
More precisely,
• if uplo = 'U'${\mathbf{uplo}}=\text{'U'}$, the upper triangle of A$A$ must be stored with element Aij${A}_{ij}$ in ap(i + j(j1) / 2)${\mathbf{ap}}\left(i+j\left(j-1\right)/2\right)$ for ij$i\le j$;
• if uplo = 'L'${\mathbf{uplo}}=\text{'L'}$, the lower triangle of A$A$ must be stored with element Aij${A}_{ij}$ in ap(i + (2nj)(j1) / 2)${\mathbf{ap}}\left(i+\left(2n-j\right)\left(j-1\right)/2\right)$ for ij$i\ge j$.

None.

None.

### Output Parameters

1:     ap( : $:$) – double array
Note: the dimension of the array ap must be at least max (1,n × (n + 1) / 2)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×\left({\mathbf{n}}+1\right)/2\right)$.
ap stores the tridiagonal matrix T$T$ and details of the orthogonal matrix Q$Q$.
2:     d(n) – double array
The diagonal elements of the tridiagonal matrix T$T$.
3:     e(n1${\mathbf{n}}-1$) – double array
The off-diagonal elements of the tridiagonal matrix T$T$.
4:     tau(n1${\mathbf{n}}-1$) – double array
Further details of the orthogonal matrix Q$Q$.
5:     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

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: ap, 4: d, 5: e, 6: tau, 7: info.

## Accuracy

The computed tridiagonal matrix T$T$ is exactly similar to a nearby matrix (A + E)$\left(A+E\right)$, where
 ‖E‖2 ≤ c(n) ε ‖A‖2 , $‖E‖2≤ c(n) ε ‖A‖2 ,$
c(n)$c\left(n\right)$ is a modestly increasing function of n$n$, and ε$\epsilon$ is the machine precision.
The elements of T$T$ themselves may be sensitive to small perturbations in A$A$ or to rounding errors in the computation, but this does not affect the stability of the eigenvalues and eigenvectors.

The total number of floating point operations is approximately (4/3) n3 $\frac{4}{3}{n}^{3}$.
To form the orthogonal matrix Q$Q$ nag_lapack_dsptrd (f08ge) may be followed by a call to nag_lapack_dopgtr (f08gf):
```[q, info] = f08gf(uplo, n, ap, tau);
```
To apply Q$Q$ to an n$n$ by p$p$ real matrix C$C$ nag_lapack_dsptrd (f08ge) may be followed by a call to nag_lapack_dopmtr (f08gg). For example,
```[ap, c, info] = f08gg('Left', uplo, 'No Transpose', ap, tau, c);
```
forms the matrix product QC$QC$.
The complex analogue of this function is nag_lapack_zhptrd (f08gs).

## Example

```function nag_lapack_dsptrd_example
uplo = 'L';
n = int64(4);
ap = [2.07;
3.87;
4.2;
-1.15;
-0.21;
1.87;
0.63;
1.15;
2.06;
-1.81];
[apOut, d, e, tau, info] = nag_lapack_dsptrd(uplo, n, ap)
```
```

apOut =

2.0700
-5.8258
0.4332
-0.1186
1.4741
2.6240
0.8063
-0.6492
0.9163
-1.6949

d =

2.0700
1.4741
-0.6492
-1.6949

e =

-5.8258
2.6240
0.9163

tau =

1.6643
1.2120
0

info =

0

```
```function f08ge_example
uplo = 'L';
n = int64(4);
ap = [2.07;
3.87;
4.2;
-1.15;
-0.21;
1.87;
0.63;
1.15;
2.06;
-1.81];
[apOut, d, e, tau, info] = f08ge(uplo, n, ap)
```
```

apOut =

2.0700
-5.8258
0.4332
-0.1186
1.4741
2.6240
0.8063
-0.6492
0.9163
-1.6949

d =

2.0700
1.4741
-0.6492
-1.6949

e =

-5.8258
2.6240
0.9163

tau =

1.6643
1.2120
0

info =

0

```