Previous Next Contents Generated Index Doc Set Home



Eigenvalues and Eigenvectors of a Symmetric Matrix (Simple Driver)

The subroutines described in this section compute the eigenvalues and, optionally, the eigenvectors of a symmetric matrix A. The eigenvectors are normalized to have a Euclidean norm of 1. Note that the expert driver xSYEVX is also available.

Calling Sequence

CALL DSYEV 
(JOBZ, UPLO, N, DA, LDA, DW, DWORK, LDWORK, INFO)
CALL SSYEV 
(JOBZ, UPLO, N, SA, LDA, SW, SWORK, LDWORK, INFO)






void dsyev 
(char jobz, char uplo, int n, double *da, int lda, 
double *dw, int *info)
void ssyev 
(char jobz, char uplo, int n, float *sa, int lda, float 
*sw, 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.

UPLO

Indicates whether xA contains the upper or lower triangle of the matrix. The legal values for UPLO are listed below. Any values not listed below are illegal.

'U' or 'u'

xA contains the upper triangle.

'L' or 'l'

xA contains the lower triangle.

N

Order of the matrix A. N 0.

xA

On entry, the upper or lower triangle of the matrix A.

On exit, if JOBZ = 'V' or 'v' then A contains the orthonormal eigenvectors. If JOBZ = 'N' or 'n' then all of A is overwritten.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA max(1, N).

xW

On exit, the N eigenvalues in ascending order.

xWORK

Scratch array with a dimension of LDWORK.

LDWORK

Leading dimension of the array WORK as specified in a dimension or type statement. LDWORK max(1, 3 × N - 1).

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           LDA, LDWORK, N
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDWORK = 3 * N - 1)
C
      DOUBLE PRECISION  A(LDA,N), EVALS(N), WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DSYEV
      INTRINSIC         ABS
C
C     Initialize the array A to store the matrix A shown below.
C
C         9  1  1
C     A = 1  9  1
C         1  1  9
C
      DATA A / 9.0D0, 8D8, 8D8, 1.0D0, 9.0D0, 8D8, 1.0D0, 1.0D0,
     $         9.0D0 /
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (A(ICOL,IROW), ICOL = 1, IROW - 1),
     $              (A(IROW,ICOL), ICOL = IROW, N)
  100 CONTINUE
      PRINT 1020
      DO 110, IROW = 1, N
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  110 CONTINUE
C
C     Compute the eigenvalues and eigenvectors of A.
C
      CALL DSYEV ('VALUES AND VECTORS', 'UPPER TRIANGULAR A', N,
     $            A, LDA, EVALS, WORK, LDWORK, INFO)
      IF (INFO .NE. 0) THEN
        IF (INFO .LT. 0) THEN
          PRINT 1030, ABS(INFO)
          STOP 1
        ELSE
          PRINT 1040, INFO
          STOP 2
        END IF
      END IF
C
C     Print the eigenvalues and eigenvectors.
C
      PRINT 1050
      DO 120, ICOL = 1, N
        PRINT 1060, EVALS(ICOL), (A(IROW,ICOL), IROW = 1, N)
  120 CONTINUE
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (3(3X, F4.1))
 1020 FORMAT (/1X, 'A in symmetric form:  (* in unused elements)')
 1030 FORMAT (/1X, 'Illegal argument to DSYEV, argument #', I2)
 1040 FORMAT (/1X, 'Convergence failure, INFO = ', I2)
 1050 FORMAT (/1X, 'Eigenvalue', 4X, 'Eigenvector**T')
 1060 FORMAT (1X, F7.2, 5X, '[', F4.2, ', ', F4.2, ', ', 
     $        F4.2, ']')
C
      END
 

Sample Output

 
 A in full form:
    9.0    1.0    1.0
    1.0    9.0    1.0
    1.0    1.0    9.0



 A in symmetric form:  (* in unused elements)
    9.0    1.0    1.0
   ****    9.0    1.0
   ****   ****    9.0



 Eigenvalue    Eigenvector**T
    8.00     [0.04, -.73, 0.69]
    8.00     [0.82, -.37, -.44]
   11.00     [0.58, 0.58, 0.58]






Previous Next Contents Generated Index Doc Set Home