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_dstein (f08jk)

## Purpose

nag_lapack_dstein (f08jk) computes the eigenvectors of a real symmetric tridiagonal matrix corresponding to specified eigenvalues, by inverse iteration.

## Syntax

[z, ifailv, info] = f08jk(d, e, m, w, iblock, isplit, 'n', n)
[z, ifailv, info] = nag_lapack_dstein(d, e, m, w, iblock, isplit, 'n', n)

## Description

nag_lapack_dstein (f08jk) computes the eigenvectors of a real symmetric tridiagonal matrix T$T$ corresponding to specified eigenvalues, by inverse iteration (see Jessup and Ipsen (1992)). It is designed to be used in particular after the specified eigenvalues have been computed by nag_lapack_dstebz (f08jj) with order = 'B'${\mathbf{order}}=\text{'B'}$, but may also be used when the eigenvalues have been computed by other functions in Chapters F02 or F08.
If T$T$ has been formed by reduction of a full real symmetric matrix A$A$ to tridiagonal form, then eigenvectors of T$T$ may be transformed to eigenvectors of A$A$ by a call to nag_lapack_dormtr (f08fg) or nag_lapack_dopmtr (f08gg).
nag_lapack_dstebz (f08jj) determines whether the matrix T$T$ splits into block diagonal form:
T =
 T1 T2 . . . Tp
$T = T1 T2 . . . Tp$
and passes details of the block structure to this function in the arrays iblock and isplit. This function can then take advantage of the block structure by performing inverse iteration on each block Ti${T}_{i}$ separately, which is more efficient than using the whole matrix.

## References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Jessup E and Ipsen I C F (1992) Improving the accuracy of inverse iteration SIAM J. Sci. Statist. Comput. 13 550–572

## Parameters

### Compulsory Input Parameters

1:     d( : $:$) – double array
Note: the dimension of the array d must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The diagonal elements of the tridiagonal matrix T$T$.
2:     e( : $:$) – double array
Note: the dimension of the array e must be at least max (1,n1)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$.
The off-diagonal elements of the tridiagonal matrix T$T$.
3:     m – int64int32nag_int scalar
m$m$, the number of eigenvectors to be returned.
Constraint: 0mn$0\le {\mathbf{m}}\le {\mathbf{n}}$.
4:     w( : $:$) – double array
Note: the dimension of the array w must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The eigenvalues of the tridiagonal matrix T$T$ stored in w(1)${\mathbf{w}}\left(1\right)$ to w(m)${\mathbf{w}}\left(m\right)$, as returned by nag_lapack_dstebz (f08jj) with order = 'B'${\mathbf{order}}=\text{'B'}$. Eigenvalues associated with the first sub-matrix must be supplied first, in nondecreasing order; then those associated with the second sub-matrix, again in nondecreasing order; and so on.
Constraint: if iblock(i) = iblock(i + 1)${\mathbf{iblock}}\left(\mathit{i}\right)={\mathbf{iblock}}\left(\mathit{i}+1\right)$, w(i)w(i + 1)${\mathbf{w}}\left(\mathit{i}\right)\le {\mathbf{w}}\left(\mathit{i}+1\right)$, for i = 1,2,,m1$\mathit{i}=1,2,\dots ,{\mathbf{m}}-1$.
5:     iblock( : $:$) – int64int32nag_int array
Note: the dimension of the array iblock must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The first m$m$ elements must contain the sub-matrix indices associated with the specified eigenvalues, as returned by nag_lapack_dstebz (f08jj) with order = 'B'${\mathbf{order}}=\text{'B'}$. If the eigenvalues were not computed by nag_lapack_dstebz (f08jj) with order = 'B'${\mathbf{order}}=\text{'B'}$, set iblock(i)${\mathbf{iblock}}\left(\mathit{i}\right)$ to 1$1$, for i = 1,2,,m$\mathit{i}=1,2,\dots ,m$.
Constraint: iblock(i)iblock(i + 1)${\mathbf{iblock}}\left(\mathit{i}\right)\le {\mathbf{iblock}}\left(\mathit{i}+1\right)$, for i = 1,2,,m1$\mathit{i}=1,2,\dots ,{\mathbf{m}}-1$.
6:     isplit( : $:$) – int64int32nag_int array
Note: the dimension of the array isplit must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The points at which T$T$ breaks up into sub-matrices, as returned by nag_lapack_dstebz (f08jj) with order = 'B'${\mathbf{order}}=\text{'B'}$. If the eigenvalues were not computed by nag_lapack_dstebz (f08jj) with order = 'B'${\mathbf{order}}=\text{'B'}$, set isplit(1)${\mathbf{isplit}}\left(1\right)$ to n.

### Optional Input Parameters

1:     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$n$, the order of the matrix T$T$.
Constraint: n0${\mathbf{n}}\ge 0$.

ldz work iwork

### Output Parameters

1:     z(ldz, : $:$) – double array
The first dimension of the array z 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,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
ldz max (1,n) $\mathit{ldz}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The m$m$ eigenvectors, stored as columns of Z$Z$; the i$i$th column corresponds to the i$i$th specified eigenvalue, unless ${\mathbf{INFO}}>{\mathbf{0}}$ (in which case see Section [Error Indicators and Warnings]).
2:     ifailv(m) – int64int32nag_int array
If info = i > 0${\mathbf{info}}=i>0$, the first i$i$ elements of ifailv contain the indices of any eigenvectors which have failed to converge. The rest of the first m elements of ifailv are set to 0$0$.
3:     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: n, 2: d, 3: e, 4: m, 5: w, 6: iblock, 7: isplit, 8: z, 9: ldz, 10: work, 11: iwork, 12: ifailv, 13: 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$, then i$i$ eigenvectors (as indicated by the parameter ifailv above) each failed to converge in five iterations. The current iterate after five iterations is stored in the corresponding column of z.

## Accuracy

Each computed eigenvector zi${z}_{i}$ is the exact eigenvector of a nearby matrix A + Ei$A+{E}_{i}$, such that
 ‖Ei‖ = O(ε) ‖A‖ , $‖Ei‖ = O(ε) ‖A‖ ,$
where ε$\epsilon$ is the machine precision. Hence the residual is small:
 ‖Azi − λizi‖ = O(ε) ‖A‖ . $‖ A zi - λi zi ‖ = O(ε) ‖A‖ .$
However, a set of eigenvectors computed by this function may not be orthogonal to so high a degree of accuracy as those computed by nag_lapack_dsteqr (f08je).

The complex analogue of this function is nag_lapack_zstein (f08jx).

## Example

```function nag_lapack_dstein_example
side = 'Left';
uplo = 'L';
trans = 'No transpose';
a = [2.07, 0, 0, 0;
3.87, -0.21, 0, 0;
4.2, 1.87, 1.15, 0;
-1.15, 0.63, 2.06, -1.81];
vu = 0;
il = int64(1);
iu = int64(2);
abstol = 0;
[a, d, e, tau, info] = nag_lapack_dsytrd(uplo, a);
[m, nsplit, w, iblock, isplit, info] = nag_lapack_dstebz('I', 'B', 0, 0, il, iu, abstol, d, e);
[z, ifailv, info] = nag_lapack_dstein(d, e, m, w, iblock, isplit)
```
```

z =

0.5658   -0.2328
0.6869   -0.1626
-0.4396   -0.3017
0.1217    0.9101

ifailv =

0
0

info =

0

```
```function f08jk_example
side = 'Left';
uplo = 'L';
trans = 'No transpose';
a = [2.07, 0, 0, 0;
3.87, -0.21, 0, 0;
4.2, 1.87, 1.15, 0;
-1.15, 0.63, 2.06, -1.81];
vu = 0;
il = int64(1);
iu = int64(2);
abstol = 0;
[a, d, e, tau, info] = f08fe(uplo, a);
[m, nsplit, w, iblock, isplit, info] = f08jj('I', 'B', 0, 0, il, iu, abstol, d, e);
[z, ifailv, info] = f08jk(d, e, m, w, iblock, isplit)
```
```

z =

0.5658   -0.2328
0.6869   -0.1626
-0.4396   -0.3017
0.1217    0.9101

ifailv =

0
0

info =

0

```