# NAG Library Function Document

## 1Purpose

nag_zstein (f08jxc) computes the eigenvectors of a real symmetric tridiagonal matrix corresponding to specified eigenvalues, by inverse iteration, storing the eigenvectors in a complex array.

## 2Specification

 #include #include
 void nag_zstein (Nag_OrderType order, Integer n, const double d[], const double e[], Integer m, const double w[], const Integer iblock[], const Integer isplit[], Complex z[], Integer pdz, Integer ifailv[], NagError *fail)

## 3Description

nag_zstein (f08jxc) computes the eigenvectors of a real symmetric tridiagonal matrix $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_dstebz (f08jjc) with ${\mathbf{rank}}=\mathrm{Nag_ByBlock}$, but may also be used when the eigenvalues have been computed by other functions in Chapters f02 or f08.
The eigenvectors of $T$ are real, but are stored by this function in a complex array. If $T$ has been formed by reduction of a full complex Hermitian matrix $A$ to tridiagonal form, then eigenvectors of $T$ may be transformed to (complex) eigenvectors of $A$ by a call to nag_zunmtr (f08fuc) or nag_zupmtr (f08guc).
nag_dstebz (f08jjc) determines whether the matrix $T$ splits into block diagonal form:
 $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 ${T}_{i}$ separately, which is more efficient than using the whole matrix.

## 4References

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

## 5Arguments

1:    $\mathbf{order}$Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.
3:    $\mathbf{d}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array d must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the diagonal elements of the tridiagonal matrix $T$.
4:    $\mathbf{e}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array e must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$.
On entry: the off-diagonal elements of the tridiagonal matrix $T$.
5:    $\mathbf{m}$IntegerInput
On entry: $m$, the number of eigenvectors to be returned.
Constraint: $0\le {\mathbf{m}}\le {\mathbf{n}}$.
6:    $\mathbf{w}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array w must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the eigenvalues of the tridiagonal matrix $T$ stored in ${\mathbf{w}}\left[0\right]$ to ${\mathbf{w}}\left[m-1\right]$, as returned by nag_dstebz (f08jjc) with ${\mathbf{rank}}=\mathrm{Nag_ByBlock}$. 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 ${\mathbf{iblock}}\left[\mathit{i}\right]={\mathbf{iblock}}\left[\mathit{i}+1\right]$, ${\mathbf{w}}\left[\mathit{i}\right]\le {\mathbf{w}}\left[\mathit{i}+1\right]$, for $\mathit{i}=0,1,\dots ,{\mathbf{m}}-2$.
7:    $\mathbf{iblock}\left[\mathit{dim}\right]$const IntegerInput
Note: the dimension, dim, of the array iblock must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the first $m$ elements must contain the sub-matrix indices associated with the specified eigenvalues, as returned by nag_dstebz (f08jjc) with ${\mathbf{rank}}=\mathrm{Nag_ByBlock}$. If the eigenvalues were not computed by nag_dstebz (f08jjc) with ${\mathbf{rank}}=\mathrm{Nag_ByBlock}$, set ${\mathbf{iblock}}\left[\mathit{i}-1\right]$ to $1$, for $\mathit{i}=1,2,\dots ,m$.
Constraint: ${\mathbf{iblock}}\left[\mathit{i}\right]\le {\mathbf{iblock}}\left[\mathit{i}+1\right]$, for $\mathit{i}=0,1,\dots ,{\mathbf{m}}-2$.
8:    $\mathbf{isplit}\left[\mathit{dim}\right]$const IntegerInput
Note: the dimension, dim, of the array isplit must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the points at which $T$ breaks up into sub-matrices, as returned by nag_dstebz (f08jjc) with ${\mathbf{rank}}=\mathrm{Nag_ByBlock}$. If the eigenvalues were not computed by nag_dstebz (f08jjc) with ${\mathbf{rank}}=\mathrm{Nag_ByBlock}$, set ${\mathbf{isplit}}\left[0\right]$ to n.
9:    $\mathbf{z}\left[\mathit{dim}\right]$ComplexOutput
Note: the dimension, dim, of the array z must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdz}}×{\mathbf{m}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdz}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $Z$ is stored in
• ${\mathbf{z}}\left[\left(j-1\right)×{\mathbf{pdz}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{z}}\left[\left(i-1\right)×{\mathbf{pdz}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: the $m$ eigenvectors, stored as columns of $Z$; the $i$th column corresponds to the $i$th specified eigenvalue, unless ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_CONVERGENCE (in which case see Section 6).
10:  $\mathbf{pdz}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array z.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
11:  $\mathbf{ifailv}\left[{\mathbf{m}}\right]$IntegerOutput
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{errnum}=i>0$, the first $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$.
12:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_CONSTRAINT
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$, ${\mathbf{iblock}}\left[\mathit{i}\right]{\mathbf{iblock}}\left[\mathit{i}+1\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{w}}\left[\mathit{i}\right]{\mathbf{w}}\left[\mathit{i}+1\right]=〈\mathit{\text{value}}〉$.
Constraint: , for $\mathit{i}=0,1,\dots ,{\mathbf{m}}-2$
NE_CONVERGENCE
$〈\mathit{\text{value}}〉$ eigenvectors (as indicated by argument ifailv) each failed to converge in five iterations. The current iterate after five iterations is stored in the corresponding column of z.
NE_INT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pdz}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdz}}>0$.
NE_INT_2
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: $0\le {\mathbf{m}}\le {\mathbf{n}}$.
On entry, ${\mathbf{pdz}}=〈\mathit{\text{value}}〉$ and ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
On entry, ${\mathbf{pdz}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INT_ARRAY
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$ and ${\mathbf{iblock}}\left[\mathit{i}\right]{\mathbf{iblock}}\left[\mathit{i}+1\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{iblock}}\left[\mathit{i}\right]\le {\mathbf{iblock}}\left[\mathit{i}+1\right]$, for $\mathit{i}=0,1,\dots ,{\mathbf{m}}-2$
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

Each computed eigenvector ${z}_{i}$ is the exact eigenvector of a nearby matrix $A+{E}_{i}$, such that
 $Ei = Oε A ,$
where $\epsilon$ is the machine precision. Hence the residual is small:
 $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_zsteqr (f08jsc).

## 8Parallelism and Performance

nag_zstein (f08jxc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_zstein (f08jxc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.