# ?heevx

Computes selected eigenvalues and, optionally, eigenvectors of a Hermitian matrix.

## Syntax

FORTRAN 77:

call cheevx(jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, work, lwork, rwork, iwork, ifail, info)

call zheevx(jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, work, lwork, rwork, iwork, ifail, info)

Fortran 95:

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

## Description

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

Note that for most cases of complex Hermetian eigenvalue problems the default choice should be ?heevr function as its underlying algorithm is faster and uses less workspace. ?heevx is faster for a few selected eigenvalues.

## 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', 'V', or 'I'.

  If `range = 'A'`, all eigenvalues will be found.

  If `range = 'V'`, all eigenvalues in the half-open interval (vl, vu] will be found.

  If `range = 'I'`, the eigenvalues with indices il through iu will be found.

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

  COMPLEX for cheevx

  DOUBLE COMPLEX for zheevx.

  Arrays:

  a(lda,*) is an array containing either upper or lower triangular part of the Hermitian 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 cheevx

  DOUBLE PRECISION for zheevx.

  If `range = 'V'`, the lower and upper bounds of the interval to be searched for eigenvalues; vl ≤ vu. Not referenced if `range = 'A'`or 'I'.

il, iu

  INTEGER.

  If `range = 'I'`, the indices of the smallest and largest eigenvalues to be returned. Constraints:

  1 ≤ il ≤ iu ≤ n, if `n > 0`;il = 1 and `iu = 0`, if `n = 0`. Not referenced if `range = 'A'`or 'V'.

abstol

  REAL for cheevx

  DOUBLE PRECISION for zheevx. The absolute error tolerance for the eigenvalues. See Application Notes for more information.

ldz

  INTEGER. The first dimension of the output array z; `ldz ≥ 1`.

  If `jobz = 'V'`, then `ldz ≥max(1, n)`.

lwork

  INTEGER.

  The dimension of the array work.

  `lwork ≥ 1` if `n≤1`; otherwise at least `2*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.

  See Application Notes for the suggested value of lwork.

rwork

  REAL for cheevx

  DOUBLE PRECISION for zheevx.

  Workspace array, DIMENSION at least max(1, 7n).

iwork

  INTEGER. Workspace array, DIMENSION at least max(1, 5n).

## 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

  REAL for cheevx

  DOUBLE PRECISION for zheevx

  Array, DIMENSION at least max(1, n). The first m elements contain the selected eigenvalues of the matrix A in ascending order.

z

  COMPLEX for cheevx

  DOUBLE COMPLEX for zheevx.

  Array z(ldz,*) contains eigenvectors.

  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 A corresponding to the selected eigenvalues, with the i-th column of z holding the eigenvector associated with w(i).

  If an eigenvector fails to converge, then that column of z contains the latest approximation to the eigenvector, and the index of the eigenvector is returned in ifail.

  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 upper bound must be used.

work(1)

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

ifail

  INTEGER.

  Array, DIMENSION at least max(1, n).

  If `jobz = 'V'`, then if `info = 0`, the first m elements of ifail are zero; if `info > 0`, then ifail contains the indices of the eigenvectors that failed to converge.

  If `jobz = 'V'`, then ifail is not referenced.

info

  INTEGER.

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

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

  If `info = i`, then i eigenvectors failed to converge; their indices are stored in the array ifail.

## 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 heevx 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).

ifail

  Holds the vector of length (n).

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 ifail 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+1)*n`, where nb is the maximum of the blocksize for ?hetrd and ?unmtr returned by ilaenv.

If you are in doubt how much workspace to supply, use a generous value of lwork for the first run or set `lwork = -1`.

If you choose the first option and set any of admissible lwork sizes, which is no less than the minimal value described, 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 on exit. Use this value (`work(1)`) for subsequent runs.

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

Note that if you set lwork to less than the minimal required value and not -1, the routine returns immediately with an error exit and does not provide any information on the recommended workspace.

An approximate eigenvalue is accepted as converged when it is determined to lie in an interval [a,b] of width less than or equal to `abstol+ε*max(|a|,|b|)` , where `ε` is the machine precision.

If abstol is less than or equal to zero, then `ε*|T|` will be used in its place, where `|T|` is the 1-norm of the tridiagonal matrix obtained by reducing A to tridiagonal form. Eigenvalues will be computed most accurately when abstol is set to twice the underflow threshold 2*slamch('S'), not zero.

If this routine returns with `info > 0`, indicating that some eigenvectors did not converge, try setting abstol to 2*slamch('S').

Parent topic: Symmetric Eigenproblems