# ?stemr

Computes selected eigenvalues and eigenvectors of a real symmetric tridiagonal matrix.

## Syntax

FORTRAN 77:

call sstemr(jobz, range, n, d, e, vl, vu, il, iu, m, w, z, ldz, nzc, isuppz, tryrac, work, lwork, iwork, liwork, info)

call dstemr(jobz, range, n, d, e, vl, vu, il, iu, m, w, z, ldz, nzc, isuppz, tryrac, work, lwork, iwork, liwork, info)

call cstemr(jobz, range, n, d, e, vl, vu, il, iu, m, w, z, ldz, nzc, isuppz, tryrac, work, lwork, iwork, liwork, info)

call zstemr(jobz, range, n, d, e, vl, vu, il, iu, m, w, z, ldz, nzc, isuppz, tryrac, work, lwork, iwork, liwork, info)

## Description

This routine computes selected eigenvalues and, optionally, eigenvectors of a real symmetric tridiagonal matrix T. Any such unreduced matrix has a well defined set of pairwise different real eigenvalues, the corresponding real eigenvectors are pairwise orthogonal.

The spectrum may be computed either completely or partially by specifying either an interval `(vl,vu]` or a range of indices `il:iu` for the desired eigenvalues.

Depending on the number of desired eigenvalues, these are computed either by bisection or the dqds algorithm. Numerically orthogonal eigenvectors are computed by the use of various suitable L*D*LT factorizations near clusters of close eigenvalues (referred to as RRRs, Relatively Robust Representations). An informal sketch of the algorithm follows.

For each unreduced block (submatrix) of T,

1. Compute `T - sigma*I = L*D*LT`, so that L and D define all the wanted eigenvalues to high relative accuracy. This means that small relative changes in the entries of L and D cause only small relative changes in the eigenvalues and eigenvectors. The standard (unfactored) representation of the tridiagonal matrix T does not have this property in general.

2. Compute the eigenvalues to suitable accuracy. If the eigenvectors are desired, the algorithm attains full accuracy of the computed eigenvalues only right before the corresponding vectors have to be computed, see steps c and d.

3. For each cluster of close eigenvalues, select a new shift close to the cluster, find a new factorization, and refine the shifted eigenvalues to suitable accuracy.

4. For each eigenvalue with a large enough relative separation compute the corresponding eigenvector by forming a rank revealing twisted factorization. Go back to step c for any clusters that remain.

For more details, see: [Dhillon04], [Dhillon04-02], [Dhillon97]

The routine works only on machines which follow IEEE-754 floating-point standard in their handling of infinities and NaNs (NaN stands for "not a number"). This permits the use of efficient inner loops avoiding a check for zero divisors.

LAPACK routines can be used to reduce a complex Hermitean matrix to real symmetric tridiagonal form.

(Any complex Hermitean tridiagonal matrix has real values on its diagonal and potentially complex numbers on its off-diagonals. By applying a similarity transform with an appropriate diagonal matrix `diag(1,e{i \phy_1}, ... , e{i \phy_{n-1}})`, the complex Hermitean matrix can be transformed into a real symmetric matrix and complex arithmetic can be entirely avoided.) While the eigenvectors of the real symmetric tridiagonal matrix are real, the eigenvectors of original complex Hermitean matrix have complex entries in general. Since LAPACK drivers overwrite the matrix data with the eigenvectors, zstemr accepts complex workspace to facilitate interoperability with zunmtr or zupmtr.

## Input Parameters

jobz

  CHARACTER*1. Must be 'N' or 'V'.

  If `jobz = 'N'`, then only eigenvalues are computed.

  If `jobz = 'V'`, then eigenvalues and eigenvectors are computed.

range

  CHARACTER*1. Must be 'A' or 'V' or 'I'.

  If `range = 'A'`, the routine computes all eigenvalues.

  If `range = 'V'`, the routine computes all eigenvalues in the half-open interval: `(vl, vu]`.

  If `range = 'I'`, the routine computes eigenvalues with indices il to iu.

n

  INTEGER. The order of the matrix T (`n≥0`).

d

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  Array, DIMENSION (n).

  Contains n diagonal elements of the tridiagonal matrix T.

e

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  Array, DIMENSION (`n-1`).

  Contains `(n-1)` off-diagonal elements of the tridiagonal matrix T in elements `1` to `n-1` of `e`. `e(n)` need not be set on input, but is used internally as workspace.

vl, vu

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  If `range = 'V'`, the lower and upper bounds of the interval to be searched for eigenvalues. Constraint: `vl<vu`.

  If `range = 'A'` or 'I', vl and vu are not referenced.

il, iu

  INTEGER.

  If `range = 'I'`, the indices in ascending order of the smallest and largest eigenvalues to be returned.

  Constraint: `1≤`il≤iu`≤n`, if `n>0`.

  If `range = 'A'` or 'V', il and iu are not referenced.

ldz

  INTEGER. The leading dimension of the output array z.

  if `jobz = 'V'`, then `ldz ≥ max(1, n)`;

  `ldz ≥ 1` otherwise.

nzc

  INTEGER. The number of eigenvectors to be held in the array z.

  If `range = 'A'`, then `nzc≥max(1, n)`;

  If `range = 'V'`, then `nzc` is greater than or equal to the number of eigenvalues in the half-open interval: `(vl, vu]`.

  If `range = 'I'`, then `nzc≥il+iu+1`.

  This value is returned as the first entry of the array z, and no error message related to nzc is issued by the routine xerbla.

tryrac

  LOGICAL.

  If `tryrac = .TRUE.`, it indicates that the code should check whether the tridiagonal matrix defines its eigenvalues to high relative accuracy. If so, the code uses relative-accuracy preserving algorithms that might be (a bit) slower depending on the matrix. If the matrix does not define its eigenvalues to high relative accuracy, the code can uses possibly faster algorithms.

  If `tryrac = .FALSE.`, the code is not required to guarantee relatively accurate eigenvalues and can use the fastest possible techniques.

work

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  Workspace array, DIMENSION (lwork).

lwork

  INTEGER.

  The dimension of the array work,

  `lwork≥max(1, 18*n)`.

  If `lwork=-1`, then a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array, and no error message related to lwork is issued by xerbla.

iwork

  INTEGER.

  Workspace array, DIMENSION (liwork).

liwork

  INTEGER.

  The dimension of the array iwork.

  `lwork≥max(1, 10*n)` if the eigenvectors are desired, and `lwork≥max(1, 8*n)` if only the eigenvalues are to be computed.

  If `liwork=-1`, then a workspace query is assumed; the routine only calculates the optimal size of the iwork array, returns this value as the first entry of the iwork array, and no error message related to liwork is issued by xerbla.

## Output Parameters

e

  On exit, the array e is overwritten.

m

  INTEGER.

  The total number of eigenvalues found, `0≤m≤n`.

  If `range = 'A'`, then `m=n`, and if If `range = 'I'`, then `m=iu-il+1`.

w

  REAL for single precision flavors

  DOUBLE PRECISION for double precision flavors.

  Array, DIMENSION (n).

  The first m elements contain the selected eigenvalues in ascending order.
z

  REAL for sstemr

  DOUBLE PRECISION for dstemr

  COMPLEX for cstemr

  DOUBLE COMPLEX for zstemr.

  Array z(ldz, *), the second dimension of z must be at least `max(1, m)`.

  If `jobz = 'V'`, and `info = 0`, then the first m columns of z contain the orthonormal eigenvectors of the matrix T corresponding to the selected eigenvalues, with the i-th column of z holding the eigenvector associated with `w(i)`.

  If `jobz = 'N'`, then z is not referenced.

  Note: you must ensure that at least `max(1,m)` columns are supplied in the array z ; if `range = 'V'`, the exact value of m is not known in advance and an can be computed with a workspace query by setting `nzc=-1`, see description of the parameter nzc.

isuppz

  INTEGER.

  Array, DIMENSION (`2*max(1, m)`).

  The support of the eigenvectors in z, that is the indices indicating the nonzero elements in z. The `i`-th computed eigenvector is nonzero only in elements `isuppz(2*i-1)` through isuppz`(2*i)`. This is relevant in the case when the matrix is split. isuppz is only accessed when jobz = 'V' and n>0.

tryrac

  On exit, `TRUE.` tryrac is set to .`FALSE.` if the matrix does not define its eigenvalues to high relative accuracy.

work(1)

  On exit, if `info = 0`, then `work(1)` returns the optimal (and minimal) size of lwork.

iwork(1)

  On exit, if `info = 0`, then `iwork(1)` returns the optimal size of liwork.

info

  INTEGER.

  If `= 0`, the execution is successful.

  If `info = -i`, the `i`-th parameter had an illegal value.

  If `info = 1`, internal error in ?larre occurred,

  if `info = 2`, internal error in ?larrv occurred.

Parent topic: Symmetric Eigenvalue Problems