Previous Next Contents Generated Index Doc Set Home



Eigenvalues and Eigenvectors of a Symmetric Tridiagonal Matrix (Expert Driver)

The subroutines described in this section compute the eigenvalues and, optionally, the eigenvectors of a symmetric tridiagonal matrix A. The eigenvectors are normalized to have a Euclidean norm of 1. Eigenvalues and eigenvectors can be selected by specifying either a range of values or a range of indices for the desired eigenvalues. Note that the simple driver xSTEV is also available.

Calling Sequence

CALL DSTEVX 
(JOBZ, RANGE, N, DDIAG, DOFFD, DVL, DVU, IL, IU, 
DABTOL, NFOUND, DW, DZ, LDZ, DWORK, IWORK2, IFAIL, 
INFO)
CALL SSTEVX 
(JOBZ, RANGE, N, SDIAG, SOFFD, SVL, SVU, IL, IU, 
SABTOL, NFOUND, SW, SZ, LDZ, SWORK, IWORK2, IFAIL, 
INFO)






void dstevx 
(char jobz, char range, int n, double *ddiag, double 
*doffd, double dvl, double dvu, int il, int iu, double 
dabtol, int *nfound, double *dw, double *dz, int ldz, 
int *ifail, int *info)
void sstevx 
(char jobz, char range, int n, float *sdiag, float 
*soffd, float svl, float svu, int il, int iu, float 
sabtol, int *nfound, float *sw, float *sz, int ldz, int 
*ifail, int *info)

Arguments

JOBZ

Indicates whether to compute eigenvalues only or to compute both eigenvalues and eigenvectors. The legal values for JOBZ are listed below. Any values not listed below are illegal.

'N' or 'n'

Compute eigenvalues only.

'V' or 'v'

Compute both eigenvalues and eigenvectors.

RANGE

Indicates whether to compute all eigenvalues or some subset. Legal values for RANGE are shown below. Any values not shown below are illegal.

'A' or 'a'

All eigenvalues will be computed.

'I' or 'i'

The ILth through IUth eigenvalues will be computed; see the descriptions of the IL and IU arguments below.

'V' or 'v'

All eigenvalues in the half-open interval (VL,VU] will be computed; see the descriptions of the VL and VU arguments below.

N

Order of the matrix A. N 0.

xDIAG

On entry, the N diagonal elements of A.
On exit, DIAG may be multiplied by a constant factor chosen to avoid overflow or underflow in computing the eigenvalues.

xOFFD

On entry, the N-1 off-diagonal elements of A stored in elements 1 through N-1 of this N-element array. OFFD(N) does not need to be set.
On exit, OFFD may be multiplied by a constant factor chosen to avoid overflow or underflow in computing the eigenvalues.

xVL, xVU

If RANGE = 'V' or 'v' then only eigenvalues in the half-open interval (VL,VU] will be computed. Otherwise not used.

IL, IU

If RANGE = 'I' or 'i' then only the ILth through IUth eigenvalues will be computed. Otherwise not used. 1 IL IU N.

xABTOL

The absolute error tolerance for the eigenvalues. An approximate eigenvalue is considered to have converged when it lies in an interval [a,b] of width less than or equal to ABTOL + × max(|a|, |b|) where is machine precision. If ABTOL 0 then × ||T||1 will be used in its place, where ||T||1 is the 1-norm of the tridiagonal matrix obtained by reducing A to tridiagonal form.

NFOUND

On exit, the total number of eigenvalues found. 0 NFOUND N.
If RANGE = 'A' or 'a' then NFOUND = N. If RANGE = 'I' or 'i' then NFOUND = IU - IL + 1.

xW

On exit, W(1:NFOUND) contains the computed eigenvalues in ascending order.

xZ

On exit, if JOBZ = 'V' or 'v' then the first NFOUND columns of Z contain the orthonormal eigenvectors corresponding to the selected eigenvalues. If an eigenvector fails to converge then the corresponding column of Z contains an approximation to that eigenvector and its index is returned in IFAIL. If JOBZ = 'N' or 'n' then Z is not used.

Note that Z must have at least NFOUND columns. If RANGE = 'V' or 'v' then NFOUND may not be known in advance and an upper bound must be used. For A(LDZ,K) where NFOUND > K, the eigenvectors will be stored into memory with unpredictable results.

LDZ

Leading dimension of the array Z as specified in a dimension or type statement. LDZ 1. If JOBZ = 'V' or 'v' then LDZ max(1, N).

xWORK

Scratch array with a dimension of 5 × N.

IWORK2

Scratch array with a dimension of 5 × N.

IFAIL

On exit, an N-element array that indicates which eigenvectors that failed to converge. If JOBZ = 'V' or 'v' and INFO = 0 then all N elements contain zero. If INFO > 0 then IFAIL contains the indices of the eigenvectors that failed to converge. If JOBZ = 'N' or 'n' then IFAIL is not used.

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

The ith argument, where i = |INFO|, had an illegal value.

INFO > 0

There were i eigenvectors, where i = INFO, that failed to converge. Their indices are stored in IFAIL.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDEVEC, LDIWRK, LDWORK, N
      PARAMETER        (N = 4)
      PARAMETER        (LDEVEC = N)
      PARAMETER        (LDIWRK = 5 * N)
      PARAMETER        (LDWORK = 5 * N)
C
      DOUBLE PRECISION  DIAG(N), EVALS(N), EVECS(LDEVEC,N), OFF(N)
      DOUBLE PRECISION  PIDIV4, TEMP, WORK(LDWORK)
      INTEGER           ICOL, IFAIL(N), INFO, IROW, ITEMP
      INTEGER           IWORK(LDIWRK), NFOUND
C
      EXTERNAL          DSTEVX
      INTRINSIC         ABS, ATAN, COS, MIN, SIN
C
C     Initialize the array A to store the symmetric tridiagonal
C     matrix A shown below.
C
C          1       0           0       0
C     A =  0   cos(pi/4)   sin(pi/4)   0
C          0   sin(pi/4)  -cos(pi/4)   0
C          0       0           0       1
C
      PIDIV4 = ATAN(1.0D0)
      DIAG(1) = 1.0D0
      DIAG(2) = COS(PIDIV4)
      DIAG(3) = -COS(PIDIV4)
      DIAG(4) = 1.0D0
      OFF(1) = 0.0D0
      OFF(2) = SIN(PIDIV4)
      OFF(3) = 0.0D0
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (0.0D0, ICOL = 1, IROW - 2),
     $        (OFF(IROW - 1), ICOL = ABS(IROW - 2), IROW - 2),
     $        DIAG(IROW),
     $        (OFF(IROW), ICOL = 1, MIN(1, N - IROW)),
     $        (0.0D0, ICOL = IROW + 2, N)
  100 CONTINUE
C
C     Compute the eigenvalues and right eigenvectors of A.
C
      CALL DSTEVX ('VECTORS AND VALUES', 'ALL EIGENVALUES', N,
     $             DIAG, OFF, TEMP, TEMP, ITEMP, ITEMP, 0.0D0,
     $             NFOUND, EVALS, EVECS, LDEVEC, WORK, IWORK,
     $             IFAIL, INFO)
      IF (INFO .NE. 0) THEN
        IF (INFO .LT. 0) THEN
          PRINT 1020, ABS(INFO)
          STOP 1
        ELSE
          PRINT 1030, INFO
          STOP 2
        END IF
      END IF
C
C     Print the eigenvalues and eigenvectors.
C
      PRINT 1040
      DO 120, ICOL = 1, N
        PRINT 1050, DIAG(ICOL), (EVECS(IROW,ICOL), IROW = 1, N)
  120 CONTINUE
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(3X, F9.6))
 1020 FORMAT (/1X, 'Illegal argument to DSTEVX, argument #', I2)
 1030 FORMAT (/1X, 'QR failed to converge, INFO = ', I2)
 1040 FORMAT (/1X, 'Eigenvalue', 10X, 'Eigenvector**T')
 1050 FORMAT (1X, F7.2, 6X, '[', 3(F5.3, ', '), F5.3, ']')
C
      END
 

Sample Output

 
 A:
    1.000000    0.000000    0.000000    0.000000
    0.000000    0.707107    0.707107    0.000000
    0.000000    0.707107   -0.707107    0.000000
    0.000000    0.000000    0.000000    1.000000



 Eigenvalue          Eigenvector**T
    1.00      [0.000, 0.383, -.924, 0.000]
    0.71      [0.000, -.924, -.383, 0.000]
   -0.71      [1.000, 0.000, 0.000, 0.000]
    1.00      [0.000, 0.000, 0.000, 1.000]






Previous Next Contents Generated Index Doc Set Home