Previous Next Contents Generated Index Doc Set Home



Eigenvalues and Eigenvectors of a Hermitian Matrix (Simple Driver)

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

Calling Sequence

CALL ZHEEV 
(JOBZ, UPLO, N, ZA, LDA, DW, ZWORK, LDWORK, DWORK2, 
INFO)
CALL CHEEV 
(JOBZ, UPLO, N, CA, LDA, SW, CWORK, LDWORK, SWORK2, 
INFO)






void zheev 
(char jobz, char uplo, int n, doublecomplex *za, int 
lda, double *dw, int *info)
void cheev 
(char jobz, char uplo, int n, complex *ca, 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 the upper or lower triangle of A, including the diagonal, 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, 2 × N - 1).

xWORK2

Scratch array with a dimension of max(1, 3 × 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
      DOUBLE PRECISION  ZERO
      INTEGER           LDA, LDEVAL, LDWORK, LDWRK2, N
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDEVAL = N)
      PARAMETER        (LDWORK = 2 * N - 1)
      PARAMETER        (LDWRK2 = 3 * N - 2)
      PARAMETER        (ZERO = 0.0D0)
C
      DOUBLE PRECISION  EVALS(LDEVAL), WORK2(LDWRK2)
      COMPLEX*16        A(LDA,N), WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          ZHEEV
      INTRINSIC         ABS, CMPLX, CONJG, DBLE
C
C     Initialize the array A to store the coefficient array A
C     shown below.
C
C          4     4-4i    0
C     A = 4+4i    4     4-4i
C          0     4+4i    4
C
      DATA A / (4.0D0,8D8),    (8D8,8D8),      (8D8,8D8),
     $         (4.0D0,-4.0D0), (4.0D0,8D8),    (8D8,8D8),
     $         (0.0D0,0.0D0),  (4.0D0,-4.0D0), (4.0D0,8D8) /



C
C     Print the initial value of A.
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (CONJG(A(ICOL,IROW)), ICOL = 1, IROW - 1),
     $              CMPLX(DBLE(A(IROW,IROW)), ZERO),
     $              (A(IROW,ICOL), ICOL = IROW + 1, N)
  100 CONTINUE
      PRINT 1020
      DO 110, IROW = 1, N
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  110 CONTINUE
      CALL ZHEEV ('VALUES AND VECTORS', 
     $            'UPPER TRIANGLE OF A STORED', N, A, LDA, 
     $            EVALS, WORK, LDWORK, WORK2, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1040, ABS(INFO)
        STOP 1
      ELSE IF (INFO .GT. 0) THEN
        PRINT 1050
        STOP 2
      END IF
C
C     Print the eigenvalues and eigenvectors.
C
      PRINT 1060
      DO 200, IROW = 1, N
        PRINT 1070, EVALS(IROW), (A(IROW,ICOL), ICOL = 1, N)
  200 CONTINUE
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (1X, 10(: 2X, '(', F5.1, ',', F5.1, ')'))
 1020 FORMAT (/1X, 'A in Hermitian form:  (* in unused entries)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, 'Illegal argument to ZHEEV, argument #', I2)
 1050 FORMAT (1X, 'Convergence failure, INFO = ', I2)
 1060 FORMAT (/1X, 'Eigenvalue', 16X, 'Eigenvector**T')
 1070 FORMAT (1X, F8.3, 6X, '[', 3('(', F4.1, ',', F4.1, ')  '),
     $        ']')
C
      END
 

Sample Output

 
 A in full form:
   (  4.0,  0.0)  (  4.0, -4.0)  (  0.0,  0.0)
   (  4.0,  4.0)  (  4.0,  0.0)  (  4.0, -4.0)
   (  0.0,  0.0)  (  4.0,  4.0)  (  4.0,  0.0)



 A in Hermitian form:  (* in unused entries)
   (  4.0,*****)  (  4.0, -4.0)  (  0.0,  0.0)
   (*****,*****)  (  4.0,*****)  (  4.0, -4.0)
   (*****,*****)  (*****,*****)  (  4.0,*****)



 Eigenvalue                Eigenvector**T
   -4.000      [( 0.0, 0.5)  ( 0.0, 0.7)  ( 0.0, 0.5)  ]
    4.000      [( 0.5,-0.5)  ( 0.0, 0.0)  (-0.5, 0.5)  ]
   12.000      [(-0.5, 0.0)  ( 0.7, 0.0)  (-0.5, 0.0)  ]






Previous Next Contents Generated Index Doc Set Home