# ?pteqr

Computes all eigenvalues and (optionally) all eigenvectors of a real symmetric positive-definite tridiagonal matrix.

## Syntax

FORTRAN 77:

call spteqr(compz, n, d, e, z, ldz, work, info)

call dpteqr(compz, n, d, e, z, ldz, work, info)

call cpteqr(compz, n, d, e, z, ldz, work, info)

call zpteqr(compz, n, d, e, z, ldz, work, info)

Fortran 95:

call rpteqr(d, e [,z] [,compz] [,info])

call pteqr(d, e [,z] [,compz] [,info])

## Description

This routine computes all the eigenvalues and (optionally) all the eigenvectors of a real symmetric positive-definite tridiagonal matrix T. In other words, the routine can compute the spectral factorization: `T = Z*Λ*ZT`.

Here Λ is a diagonal matrix whose diagonal elements are the eigenvalues λi; Z is an orthogonal matrix whose columns are eigenvectors. Thus,

`T*zi = λi*zi` for `i = 1, 2, ..., n`.

(The routine normalizes the eigenvectors so that `||zi||2 = 1`.)

You can also use the routine for computing the eigenvalues and eigenvectors of real symmetric (or complex Hermitian) positive-definite matrices A reduced to tridiagonal form T: `A = Q*T*QH`. In this case, the spectral factorization is as follows: `A = Q*T*QH = (QZ)*Λ*(QZ)H`. Before calling ?pteqr, you must reduce A to tridiagonal form and generate the explicit matrix Q by calling the following routines:

| for real matrices: | for complex matrices:
--- | --- | ---
full storage | ?sytrd, ?orgtr | ?hetrd, ?ungtr
packed storage | ?sptrd, ?opgtr | ?hptrd, ?upgtr
band storage | ?sbtrd (vect='V') | ?hbtrd (vect='V')

The routine first factorizes T as L*D*LH where L is a unit lower bidiagonal matrix, and D is a diagonal matrix. Then it forms the bidiagonal matrix `B = L*D1/2` and calls ?bdsqr to compute the singular values of B, which are the same as the eigenvalues of T.

## Input Parameters

compz

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

  If `compz = 'N'`, the routine computes eigenvalues only.

  If `compz = 'I'`, the routine computes the eigenvalues and eigenvectors of the tridiagonal matrix T.

  If `compz = 'V'`, the routine computes the eigenvalues and eigenvectors of A (and the array z must contain the matrix Q on entry).

n

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

d, e, work

  REAL for single-precision flavors

  DOUBLE PRECISION for double-precision flavors.

  Arrays:

  d(*) contains the diagonal elements of T.

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

  e(*) contains the off-diagonal elements of T.

  The dimension of e must be at least max(1, n-1).

  work(*) is a workspace array.

  The dimension of work must be:

  at least 1 if `compz = 'N'`;

  at least max(1, 4*n-4) if `compz = 'V'` or 'I'.

z

  REAL for spteqr

  DOUBLE PRECISION for dpteqr

  COMPLEX for cpteqr

  DOUBLE COMPLEX for zpteqr.

  Array, DIMENSION (ldz,*)

  If `compz = 'N'` or 'I', z need not be set.

  If `vect = 'V'`, z must contains the n-by-n matrix Q.

  The second dimension of z must be:

  at least 1 if `compz = 'N'`;

  at least max(1, n) if `compz = 'V'` or 'I'.

ldz

  INTEGER. The first dimension of z. Constraints:

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

  ldz ≥ max(1, n) if `compz = 'V'` or 'I'.

## Output Parameters

d

  The n eigenvalues in descending order, unless `info > 0`.

  See also info.

e

  On exit, the array is overwritten.

z

  If `info = 0`, contains the n orthonormal eigenvectors, stored by columns. (The i-th column corresponds to the i-th eigenvalue.)

info

  INTEGER.

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

  If `info = i`, the leading minor of order i (and hence T itself) is not positive-definite.

  If `info = n + i`, the algorithm for computing singular values failed to converge; i off-diagonal elements have not converged to zero.

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

## 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 pteqr interface are the following:

d

  Holds the vector of length (n).

e

  Holds the vector of length (n-1).

z

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

compz

  If omitted, this argument is restored based on the presence of argument z as follows:

  `compz = 'I'`, if z is present,

  `compz = 'N'`, if z is omitted.

  If present, compz must be equal to 'I' or 'V' and the argument z must also be present. Note that there will be an error condition if compz is present and z omitted.

Note that two variants of Fortran 95 interface for pteqr routine are needed because of an ambiguous choice between real and complex cases appear when z is omitted. Thus, the name rpteqr is used in real cases (single or double precision), and the name pteqr is used in complex cases (single or double precision).

## Application Notes

If λi is an exact eigenvalue, and μi is the corresponding computed value, then

`|μi - λi| ≤ c(n)*ε*K*λi`

where c(n) is a modestly increasing function of n, ε is the machine precision, and `K = ||DTD||2 *||(DTD)-1||2`, D is diagonal with `dii = tii-1/2`.

If zi is the corresponding exact eigenvector, and wi is the corresponding computed vector, then the angle θ(zi, wi) between them is bounded as follows:

`θ(ui, wi) ≤ c(n)εK / mini≠j(|λi - λj|/|λi + λj|)`.

Here `mini≠j(|λi - λj|/|λi + λj|)` is the relative gap between λi and the other eigenvalues.

The total number of floating-point operations depends on how rapidly the algorithm converges.

Typically, it is about

`30n2` if `compz = 'N'`;

`6n3` (for complex flavors, `12n3`) if `compz = 'V'` or 'I'.

Parent topic: Symmetric Eigenvalue Problems