# ?syevr

Computes selected eigenvalues and, optionally, eigenvectors of a real symmetric matrix using the Relatively Robust Representations.

## Syntax

FORTRAN 77:

call ssyevr(jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, isuppz, work, lwork, iwork, liwork, info)

call dsyevr(jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, isuppz, work, lwork, iwork, liwork, info)

Fortran 95:

call syevr(a, w [,uplo] [,z] [,vl] [,vu] [,il] [,iu] [,m] [,isuppz] [,abstol] [,info])

## Description

This routine computes selected eigenvalues and, optionally, eigenvectors of a real symmetric matrix A. Eigenvalues and eigenvectors can be selected by specifying either a range of values or a range of indices for the desired eigenvalues.

The routine first reduces the matrix A to tridiagonal form T with a call to ?sytrd. Then, whenever possible, ?syevr calls ?stemr to compute the eigenspectrum using Relatively Robust Representations. ?stemr computes eigenvalues by the dqds algorithm, while orthogonal eigenvectors are computed from various “good” L*D*LT representations (also known as Relatively Robust Representations). Gram-Schmidt orthogonalization is avoided as far as possible. More specifically, the various steps of the algorithm are as follows. For the each unreduced block of T:

1. Compute `T - σ*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 D and L 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.

The desired accuracy of the output can be specified by the input parameter abstol.

The routine ?syevr calls ?stemr when the full spectrum is requested on machines that conform to the IEEE-754 floating point standard. ?syevr calls ?stebz and ?stein on non-IEEE machines and when partial spectrum requests are made.

Note that ?syevr is preferable for most cases of real symmetric eigenvalue problems as its underlying algorithm is fast and uses less workspace.

## 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 eigenvalues lambda`(i)` in the half-open interval:

  `vl< lambda`(i)` ≤ vu`.

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

  For `range = 'V'`or 'I' and `iu-il < n-1`, sstebz/dstebz and sstein/dstein are called.

uplo

  CHARACTER*1. Must be 'U' or 'L'.

  If `uplo = 'U'`, a stores the upper triangular part of A.

  If `uplo = 'L'`, a stores the lower triangular part of A.

n

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

a, work

  REAL for ssyevr

  DOUBLE PRECISION for dsyevr.

  Arrays:

  a(lda,*) is an array containing either upper or lower triangular part of the symmetric matrix A, as specified by uplo.

  The second dimension of a must be at least max(1, n).

  work is a workspace array, its dimension `max(1, lwork)`.

lda

  INTEGER. The first dimension of the array a. Must be at least max(1, n).

vl, vu

  REAL for ssyevr

  DOUBLE PRECISION for dsyevr.

  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`;

  `il=1` and `iu=0`, if `n = 0`.

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

abstol

  REAL for ssyevr

  DOUBLE PRECISION for dsyevr. The absolute error tolerance to which each eigenvalue/eigenvector is required.

  If `jobz = 'V'`, the eigenvalues and eigenvectors output have residual norms bounded by abstol, and the dot products between different eigenvectors are bounded by abstol.

  If `abstol < n *eps*|T|`, then `n *eps*|T|` is used instead, where `eps` is the machine precision, and `|T|` is the 1-norm of the matrix T. The eigenvalues are computed to an accuracy of`eps*|T|` irrespective of abstol.

  If high relative accuracy is important, set abstol to ?lamch('S').

ldz

  INTEGER. The leading dimension of the output array z.

  Constraints:

  `ldz ≥ 1` if `jobz = 'N'`;

  `ldz < max(1, n)` if `jobz = 'V'`.

lwork

  INTEGER.

  The dimension of the array work.

  Constraint: `lwork ≥ max(1, 26n)`.

  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.

  See Application Notes for the suggested value of lwork.

iwork

  INTEGER. Workspace array, its dimension `max(1, liwork)`.

liwork

  INTEGER.

  The dimension of the array iwork, `lwork ≥ max(1, 10n)`.

  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

a

  On exit, the lower triangle (if `uplo = 'L'`) or the upper triangle (if `uplo = 'U'`) of A, including the diagonal, is overwritten.

m

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

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

w, z

  REAL for ssyevr

  DOUBLE PRECISION for dsyevr.

  Arrays:

  w(*), DIMENSION at least max(1, n), contains the selected eigenvalues in ascending order, stored in `w(1)` to w(m);

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

  If `jobz = 'V'`, then if `info = 0`, 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 that 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 upper bound must be used.

isuppz

  INTEGER.

  Array, DIMENSION at least 2 *max(1, m).

  The support of the eigenvectors in z, i.e., the indices indicating the nonzero elements in z. The i-th eigenvector is nonzero only in elements isuppz( 2i-1) through isuppz( 2i ). Referenced only if eigenvectors are needed (`jobz = 'V'`) and all eigenvalues are needed, that is, `range = 'A'` or `range = 'I'` and il = 1 and iu = n.

work(1)

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

iwork(1)

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

info

  INTEGER.

  If `info = 0`, the execution is successful.

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

  If `info = i`, an internal error has occurred.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or restorable arguments, see Fortran 95 Interface Conventions.

Specific details for the routine syevr interface are the following:

a

  Holds the matrix A of size (n, n).

w

  Holds the vector of length (n).

z

  Holds the matrix Z of size (n, n), where the values n and m are significant.

isuppz

  Holds the vector of length (2*m), where the values (2*m) are significant.

uplo

  Must be 'U' or 'L'. The default value is 'U'.

vl

  Default value for this element is vl = -HUGE(vl).

vu

  Default value for this element is vu = HUGE(vl).

il

  Default value for this argument is `il = 1`.

iu

  Default value for this argument is `iu = n`.

abstol

  Default value for this element is abstol = 0.0_WP.

jobz

  Restored based on the presence of the argument z as follows: `jobz = 'V'`, if z is present, `jobz = 'N'`, if z is omitted Note that there will be an error condition if isuppz is present and z is omitted.

range

  Restored based on the presence of arguments vl, vu, il, iu as follows: `range = 'V'`, if one of or both vl and vu are present, `range = 'I'`, if one of or both il and iu are present, `range = 'A'`, if none of vl, vu, il, iu is present, Note that there will be an error condition if one of or both vl and vu are present and at the same time one of or both il and iu are present.

## Application Notes

For optimum performance use `lwork ≥ (nb+6)*n`, where nb is the maximum of the blocksize for ?sytrd and ?ormtr returned by ilaenv.

If it is not clear how much workspace to supply, use a generous value of lwork (or liwork) for the first run or set `lwork = -1` (`liwork = -1`).

If lwork (or liwork) has any of admissible sizes, which is no less than the minimal value described, then the routine completes the task, though probably not so fast as with a recommended workspace, and provides the recommended workspace in the first element of the corresponding array (work, iwork) on exit. Use this value (`work(1)`, `iwork(1)`) for subsequent runs.

If `lwork = -1` (`liwork = -1`), then the routine returns immediately and provides the recommended workspace in the first element of the corresponding array (work, iwork). This operation is called a workspace query.

Note that if lwork (liwork) is less than the minimal required value and is not equal to -1, then the routine returns immediately with an error exit and does not provide any information on the recommended workspace.

Normal execution of ?stegr may create NaNs and infinities and hence may abort due to a floating point exception in environments which do not handle NaNs and infinities in the IEEE standard default manner.

Parent topic: Symmetric Eigenproblems