Previous Next Contents Generated Index Doc Set Home



Eigenvalues and Eigenvectors of a Symmetric Tridiagonal Matrix (Simple 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. Note that the expert driver xSTEVX is also available.

Calling Sequence

CALL DSTEV 
(JOBZ, N, DDIAG, DOFFD, DZ, LDZ, DWORK, INFO)
CALL SSTEV 
(JOBZ, N, SDIAG, SOFFD, SZ, LDZ, SWORK, INFO)






void dstev 
(char jobz, int n, double *ddiag, double *doffd, double 
*dz, int ldz, int *info)
void sstev 
(char jobz, int n, float *sdiag, float *soffd, float 
*sz, int ldz, 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.

N

Order of the matrix A. N 0.

xDIAG

On entry, the N diagonal elements of A.
On exit, the eigenvalues in ascending order.

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 is overwritten.

xZ

On exit, if JOBZ = 'V' or 'v' then Z contains the orthonormal eigenvectors. If JOBZ = 'N' or 'n' then Z is not used.

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 max(1, 2 × N - 2).

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

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

INFO > 0

Convergence failure.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDEVEC, LDWORK, N
      PARAMETER        (N = 4)
      PARAMETER        (LDEVEC = N)
      PARAMETER        (LDWORK = 2 * N - 2)
C
      DOUBLE PRECISION  DIAG(N), EVECS(LDEVEC,N), OFF(N), PIDIV4
      DOUBLE PRECISION  WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DSTEV
      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
C     Print the initial value of A.
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 DSTEV ('VECTORS AND VALUES', N, DIAG, OFF, EVECS,
     $            LDEVEC, WORK, 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 DSTEV, argument #', I2)
 1030 FORMAT (/1X, 'QR failed to converge, INFO = ', I2)
 1040 FORMAT (/1X, 'Eigenvalue', 4X, 'Eigenvector**T')
 1050 FORMAT (1X, F5.2, 10X, '[', 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]
  1.00          [0.000, -.924, -.383, 0.000]
  1.00          [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