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_dstevd (f08jc)

Purpose

nag_lapack_dstevd (f08jc) computes all the eigenvalues and, optionally, all the eigenvectors of a real symmetric tridiagonal matrix. If the eigenvectors are requested, then it uses a divide-and-conquer algorithm to compute eigenvalues and eigenvectors. However, if only eigenvalues are required, then it uses the Pal–Walker–Kahan variant of the $QL$ or $QR$ algorithm.

Syntax

[d, e, z, info] = f08jc(job, d, e, 'n', n)
[d, e, z, info] = nag_lapack_dstevd(job, d, e, 'n', n)

Description

nag_lapack_dstevd (f08jc) computes all the eigenvalues and, optionally, all the eigenvectors of a real symmetric tridiagonal matrix $T$. In other words, it can compute the spectral factorization of $T$ as
 $T=ZΛZT,$
where $\Lambda$ is a diagonal matrix whose diagonal elements are the eigenvalues ${\lambda }_{i}$, and $Z$ is the orthogonal matrix whose columns are the eigenvectors ${z}_{i}$. Thus
 $Tzi=λizi, i=1,2,…,n.$

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{job}$ – string (length ≥ 1)
Indicates whether eigenvectors are computed.
${\mathbf{job}}=\text{'N'}$
Only eigenvalues are computed.
${\mathbf{job}}=\text{'V'}$
Eigenvalues and eigenvectors are computed.
Constraint: ${\mathbf{job}}=\text{'N'}$ or $\text{'V'}$.
2:     $\mathrm{d}\left(:\right)$ – double array
The dimension of the array d must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The $n$ diagonal elements of the tridiagonal matrix $T$.
3:     $\mathrm{e}\left(:\right)$ – double array
The dimension of the array e must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The $n-1$ off-diagonal elements of the tridiagonal matrix $T$. The $n$th element of this array is used as workspace.

Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the first dimension of the array d and the second dimension of the array d. (An error is raised if these dimensions are not equal.)
$n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.

Output Parameters

1:     $\mathrm{d}\left(:\right)$ – double array
The dimension of the array d will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The eigenvalues of the matrix $T$ in ascending order.
2:     $\mathrm{e}\left(:\right)$ – double array
The dimension of the array e will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
e is overwritten with intermediate results.
3:     $\mathrm{z}\left(\mathit{ldz},:\right)$ – double array
The first dimension, $\mathit{ldz}$, of the array z will be
• if ${\mathbf{job}}=\text{'V'}$, $\mathit{ldz}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{job}}=\text{'N'}$, $\mathit{ldz}=1$.
The second dimension of the array z will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if ${\mathbf{job}}=\text{'V'}$ and at least $1$ if ${\mathbf{job}}=\text{'N'}$.
If ${\mathbf{job}}=\text{'V'}$, z stores the orthogonal matrix $Z$ which contains the eigenvectors of $T$.
If ${\mathbf{job}}=\text{'N'}$, z is not referenced.
4:     $\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: job, 2: n, 3: d, 4: e, 5: z, 6: ldz, 7: work, 8: lwork, 9: iwork, 10: liwork, 11: 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.
${\mathbf{info}}>0$
if ${\mathbf{info}}=i$ and ${\mathbf{job}}=\text{'N'}$, the algorithm failed to converge; $i$ elements of an intermediate tridiagonal form did not converge to zero; if ${\mathbf{info}}=i$ and ${\mathbf{job}}=\text{'V'}$, then the algorithm failed to compute an eigenvalue while working on the submatrix lying in rows and column $i/\left({\mathbf{n}}+1\right)$ through .

Accuracy

The computed eigenvalues and eigenvectors are exact for a nearby matrix $\left(T+E\right)$, where
 $E2 = Oε T2 ,$
and $\epsilon$ is the machine precision.
If ${\lambda }_{i}$ is an exact eigenvalue and ${\stackrel{~}{\lambda }}_{i}$ is the corresponding computed value, then
 $λ~i - λi ≤ c n ε T2 ,$
where $c\left(n\right)$ is a modestly increasing function of $n$.
If ${z}_{i}$ is the corresponding exact eigenvector, and ${\stackrel{~}{z}}_{i}$ is the corresponding computed eigenvector, then the angle $\theta \left({\stackrel{~}{z}}_{i},{z}_{i}\right)$ between them is bounded as follows:
 $θ z~i,zi ≤ c n ε T2 min i≠j λi - λj .$
Thus the accuracy of a computed eigenvector depends on the gap between its eigenvalue and all the other eigenvalues.

There is no complex analogue of this function.

Example

This example computes all the eigenvalues and eigenvectors of the symmetric tridiagonal matrix $T$, where
 $T = 1.0 1.0 0.0 0.0 1.0 4.0 2.0 0.0 0.0 2.0 9.0 3.0 0.0 0.0 3.0 16.0 .$
```function f08jc_example

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

% Symmetric tridiagonal A stored as diagonal and off-diagonal
n = 4;
d = [1;     4;     9;     16];
e = [1;     2;     3;     0];

% All eigenvalues and eigenvectors of A
job = 'Vectors';
[w, ~, z, info] = f08jc( ...
job, d, e);

% Normalize eigenvectors: largest element positive
for j = 1:n
[~,k] = max(abs(z(:,j)));
if z(k,j) < 0;
z(:,j) = -z(:,j);
end
end

disp(' Eigenvalues:');
disp(w');
disp(' Eigenvectors:');
disp(z);

```
```f08jc example results

Eigenvalues:
0.6476    3.5470    8.6578   17.1477

Eigenvectors:
0.9396    0.3388    0.0494    0.0034
-0.3311    0.8628    0.3781    0.0545
0.0853   -0.3648    0.8558    0.3568
-0.0167    0.0879   -0.3497    0.9326

```

Chapter Contents
Chapter Introduction
NAG Toolbox

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