F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08JVF (ZSTEDC)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F08JVF (ZSTEDC) computes all the eigenvalues and, optionally, all the eigenvectors of a real $n$ by $n$ symmetric tridiagonal matrix, or of a complex full or banded Hermitian matrix which has been reduced to tridiagonal form.

## 2  Specification

 SUBROUTINE F08JVF ( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO)
 INTEGER N, LDZ, LWORK, LRWORK, IWORK(max(1,LIWORK)), LIWORK, INFO REAL (KIND=nag_wp) D(*), E(*), RWORK(max(1,LRWORK)) COMPLEX (KIND=nag_wp) Z(LDZ,*), WORK(max(1,LWORK)) CHARACTER(1) COMPZ
The routine may be called by its LAPACK name zstedc.

## 3  Description

F08JVF (ZSTEDC) computes all the eigenvalues and, optionally, the eigenvectors of a real symmetric tridiagonal matrix $T$. That is, the routine computes the spectral factorization of $T$ given by
 $T = Z Λ ZT ,$
where $\Lambda$ is a diagonal matrix whose diagonal elements are the eigenvalues, ${\lambda }_{i}$, of $T$ and $Z$ is an orthogonal matrix whose columns are the eigenvectors, ${z}_{i}$, of $T$. Thus
 $Tzi = λi zi , i = 1,2,…,n .$
The routine may also be used to compute all the eigenvalues and eigenvectors of a complex full, or banded, Hermitian matrix $A$ which has been reduced to real tridiagonal form $T$ as
 $A = QTQH ,$
where $Q$ is unitary. The spectral factorization of $A$ is then given by
 $A = QZ Λ QZH .$
In this case $Q$ must be formed explicitly and passed to F08JVF (ZSTEDC) in the array Z, and the routine called with ${\mathbf{COMPZ}}=\text{'V'}$. Routines which may be called to form $T$ and $Q$ are
 full matrix F08FSF (ZHETRD) and F08FTF (ZUNGTR) full matrix, packed storage F08GSF (ZHPTRD) and F08GTF (ZUPGTR) band matrix F08HSF (ZHBTRD), with ${\mathbf{VECT}}=\text{'V'}$
When only eigenvalues are required then this routine calls F08JFF (DSTERF) to compute the eigenvalues of the tridiagonal matrix $T$, but when eigenvectors of $T$ are also required and the matrix is not too small, then a divide and conquer method is used, which can be much faster than F08JSF (ZSTEQR), although more storage is required.

## 4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Parameters

1:     COMPZ – CHARACTER(1)Input
On entry: indicates whether the eigenvectors are to be computed.
${\mathbf{COMPZ}}=\text{'N'}$
Only the eigenvalues are computed (and the array Z is not referenced).
${\mathbf{COMPZ}}=\text{'I'}$
The eigenvalues and eigenvectors of $T$ are computed (and the array Z is initialized by the routine).
${\mathbf{COMPZ}}=\text{'V'}$
The eigenvalues and eigenvectors of $A$ are computed (and the array Z must contain the matrix $Q$ on entry).
Constraint: ${\mathbf{COMPZ}}=\text{'N'}$, $\text{'V'}$ or $\text{'I'}$.
2:     N – INTEGERInput
On entry: $n$, the order of the symmetric tridiagonal matrix $T$.
Constraint: ${\mathbf{N}}\ge 0$.
3:     D($*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension 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.
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, the eigenvalues in ascending order.
4:     E($*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array E must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}-1\right)$.
On entry: the subdiagonal elements of the tridiagonal matrix.
On exit: E is overwritten.
5:     Z(LDZ,$*$) – COMPLEX (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array Z must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{COMPZ}}=\text{'V'}$ or $\text{'I'}$, and at least $1$ otherwise.
On entry: if ${\mathbf{COMPZ}}=\text{'V'}$, Z must contain the unitary matrix $Q$ used in the reduction to tridiagonal form.
On exit: if ${\mathbf{COMPZ}}=\text{'V'}$, Z contains the orthonormal eigenvectors of the original Hermitian matrix $A$, and if ${\mathbf{COMPZ}}=\text{'I'}$, Z contains the orthonormal eigenvectors of the symmetric tridiagonal matrix $T$.
If ${\mathbf{COMPZ}}=\text{'N'}$, Z is not referenced.
6:     LDZ – INTEGERInput
On entry: the first dimension of the array Z as declared in the (sub)program from which F08JVF (ZSTEDC) is called.
Constraints:
• if ${\mathbf{COMPZ}}=\text{'V'}$ or $\text{'I'}$, ${\mathbf{LDZ}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDZ}}\ge 1$.
7:     WORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)$) – COMPLEX (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, the real part of ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimal performance.
8:     LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08JVF (ZSTEDC) is called.
If ${\mathbf{LWORK}}=-1$, a workspace query is assumed; the routine only calculates the optimal sizes of the WORK, RWORK and IWORK arrays, returns these values as the first entries of the WORK, RWORK and IWORK arrays, and no error message related to LWORK, LRWORK or LIWORK is issued.
Constraints:
if ${\mathbf{LWORK}}\ne -1$,
• if ${\mathbf{COMPZ}}=\text{'N'}$ or $\text{'I'}$ or ${\mathbf{N}}\le 1$, LWORK must be at least $1$;
• if ${\mathbf{COMPZ}}=\text{'V'}$ and ${\mathbf{N}}>1$, LWORK must be at least ${{\mathbf{N}}}^{2}$.
Note: that for ${\mathbf{COMPZ}}=\text{'V'}$, then if N is less than or equal to the minimum divide size, usually $25$, then LWORK need only be $1$.
9:     RWORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LRWORK}}\right)$) – REAL (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, ${\mathbf{RWORK}}\left(1\right)$ returns the optimal LRWORK.
10:   LRWORK – INTEGERInput
On entry: the dimension of the array RWORK as declared in the (sub)program from which F08JVF (ZSTEDC) is called.
If ${\mathbf{LRWORK}}=-1$, a workspace query is assumed; the routine only calculates the optimal sizes of the WORK, RWORK and IWORK arrays, returns these values as the first entries of the WORK, RWORK and IWORK arrays, and no error message related to LWORK, LRWORK or LIWORK is issued.
Constraints:
if ${\mathbf{LRWORK}}\ne -1$,
• if ${\mathbf{COMPZ}}=\text{'N'}$ or ${\mathbf{N}}\le 1$, LRWORK must be at least $1$;
• if ${\mathbf{COMPZ}}=\text{'V'}$ and ${\mathbf{N}}>1$, LRWORK must be at least $1+3×{\mathbf{N}}+2×{\mathbf{N}}×lg\left({\mathbf{N}}\right)+4×{{\mathbf{N}}}^{2}$, where $lg\left({\mathbf{N}}\right)=\text{}$smallest integer $k$ such that ${2}^{k}\ge {\mathbf{N}}$;
• if ${\mathbf{COMPZ}}=\text{'I'}$ and ${\mathbf{N}}>1$, LRWORK must be at least $1+4×{\mathbf{N}}+2×{{\mathbf{N}}}^{2}$.
Note: that for ${\mathbf{COMPZ}}=\text{'I'}$ or $\text{'V'}$ then if N is less than or equal to the minimum divide size, usually $25$, then LRWORK need only be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2×\left({\mathbf{N}}-1\right)\right)$.
11:   IWORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LIWORK}}\right)$) – INTEGER arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, ${\mathbf{IWORK}}\left(1\right)$ returns the optimal LIWORK.
12:   LIWORK – INTEGERInput
On entry: the dimension of the array IWORK as declared in the (sub)program from which F08JVF (ZSTEDC) is called.
If ${\mathbf{LIWORK}}=-1$, a workspace query is assumed; the routine only calculates the optimal sizes of the WORK, RWORK and IWORK arrays, returns these values as the first entries of the WORK, RWORK and IWORK arrays, and no error message related to LWORK, LRWORK or LIWORK is issued.
Constraints:
if ${\mathbf{LIWORK}}\ne -1$,
• if ${\mathbf{COMPZ}}=\text{'N'}$ or ${\mathbf{N}}\le 1$, LIWORK must be at least $1$;
• if ${\mathbf{COMPZ}}=\text{'V'}$ or ${\mathbf{N}}>1$, LIWORK must be at least $6+6×{\mathbf{N}}+5×{\mathbf{N}}×lg\left({\mathbf{N}}\right)$;
• if ${\mathbf{COMPZ}}=\text{'I'}$ or ${\mathbf{N}}>1$, LIWORK must be at least $3+5×{\mathbf{N}}$.
13:   INFO – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{INFO}}>0$
The algorithm failed to compute an eigenvalue while working on the submatrix lying in rows and columns ${\mathbf{INFO}}/\left({\mathbf{N}}+1\right)$ through .

## 7  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 ≤ cnεT2 mini≠jλi-λj .$
Thus the accuracy of a computed eigenvector depends on the gap between its eigenvalue and all the other eigenvalues.
See Section 4.7 of Anderson et al. (1999) for further details. See also F08FLF (DDISNA).

If only eigenvalues are required, the total number of floating point operations is approximately proportional to ${n}^{2}$. When eigenvectors are required the number of operations is bounded above by approximately the same number of operations as F08JSF (ZSTEQR), but for large matrices F08JVF (ZSTEDC) is usually much faster.
The real analogue of this routine is F08JHF (DSTEDC).

## 9  Example

This example finds all the eigenvalues and eigenvectors of the Hermitian band matrix
 $A = -3.13i+0.00 1.94-2.10i -3.40+0.25i 0.00i+0.00 1.94+2.10i -1.91i+0.00 -0.82-0.89i -0.67+0.34i -3.40-0.25i -0.82+0.89i -2.87i+0.00 -2.10-0.16i 0.00i+0.00 -0.67-0.34i -2.10+0.16i 0.50i+0.00 .$
$A$ is first reduced to tridiagonal form by a call to F08HSF (ZHBTRD).

### 9.1  Program Text

Program Text (f08jvfe.f90)

### 9.2  Program Data

Program Data (f08jvfe.d)

### 9.3  Program Results

Program Results (f08jvfe.r)