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$, held in packed storage, to symmetric tridiagonal form $T$ by an orthogonal similarity transformation: $A=QT{Q}^{\mathrm{T}}$.
The matrix $Q$ is not formed explicitly but is represented as a product of $n-1$ elementary reflectors (see the F08 Chapter Introduction for details). Functions are provided to work with $Q$ in this representation (see 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:     $\mathrm{uplo}$ – string (length ≥ 1)
Indicates whether the upper or lower triangular part of $A$ is stored.
${\mathbf{uplo}}=\text{'U'}$
The upper triangular part of $A$ is stored.
${\mathbf{uplo}}=\text{'L'}$
The lower triangular part of $A$ is stored.
Constraint: ${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.
2:     $\mathrm{n}$int64int32nag_int scalar
$n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
3:     $\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 upper or lower triangle of the $n$ by $n$ symmetric matrix $A$, packed by columns.
More precisely,
• if ${\mathbf{uplo}}=\text{'U'}$, the upper triangle of $A$ 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$ 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$.

None.

### 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)$
ap stores the tridiagonal matrix $T$ and details of the orthogonal matrix $Q$.
2:     $\mathrm{d}\left({\mathbf{n}}\right)$ – double array
The diagonal elements of the tridiagonal matrix $T$.
3:     $\mathrm{e}\left({\mathbf{n}}-1\right)$ – double array
The off-diagonal elements of the tridiagonal matrix $T$.
4:     $\mathrm{tau}\left({\mathbf{n}}-1\right)$ – double array
Further details of the orthogonal matrix $Q$.
5:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

${\mathbf{info}}=-i$
If ${\mathbf{info}}=-i$, parameter $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$ is exactly similar to a nearby matrix $\left(A+E\right)$, where
 $E2≤ cn ε A2 ,$
$c\left(n\right)$ is a modestly increasing function of $n$, and $\epsilon$ is the machine precision.
The elements of $T$ themselves may be sensitive to small perturbations in $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 $\frac{4}{3}{n}^{3}$.
To form the orthogonal matrix $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$ to an $n$ by $p$ real matrix $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$.
The complex analogue of this function is nag_lapack_zhptrd (f08gs).

## Example

This example reduces the matrix $A$ to tridiagonal form, 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 ,$
using packed storage.
```function f08ge_example

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

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];

[apf, d, e, tau, info] = f08ge( ...
uplo, n, ap);

% Note: absolute values for e are displayed because the signs may change
%       with changes in sign of columns of Q.
fprintf('Diagonal and off-diagonal elements of tridiagonal form\n\n');
fprintf('    i         d           e\n');

for j = 1:n-1
fprintf('%5d%12.5f%12.5f\n', j, d(j), abs(e(j)));
end
fprintf('%5d%12.5f\n', n, d(n));

```
```f08ge example results

Diagonal and off-diagonal elements of tridiagonal form

i         d           e
1     2.07000     5.82575
2     1.47409     2.62405
3    -0.64916     0.91627
4    -1.69493
```