Previous Next Contents Generated Index Doc Set Home



Generalized Eigenvalues and Eigenvectors for Symmetric Matrices

The subroutines in this section compute the generalized eigenvalues (, ) for a pair of symmetric matrices A and B. Optionally, these subroutines can also compute the generalized eigenvectors.

A generalized eigenvalue is a ratio = / such that AX = BX or det(A-B) = 0 for general matrices A, B, and X. is typically represented as a ratio rather than as a scalar because there are reasonable interpretations for = 0, = 0, and for = = 0. A right generalized eigenvector x corresponding to a generalized eigenvalue is defined by (A - B)x = 0. A left generalized eigenvector x corresponding to a generalized eigenvalue is defined by
(A - B)Hx = 0. A good reference for generalized eigenproblems is the book Matrix Computations, 2nd. ed. by Golub and van Loan (1989, The Johns Hopkins University Press).

Calling Sequence

CALL DSYGV 
(ITYPE, JOBZ, UPLO, N, DA, LDA, DB, LDB, DW, DWORK, 
LDWORK, INFO)
CALL SSYGV 
(ITYPE, JOBZ, UPLO, N, SA, LDA, SB, LDB, SW, SWORK, 
LDWORK, INFO)






void dsygv 
(int itype, char jobz, char uplo, int n, double *da, 
int lda, double *db, int ldb, double *dw, int *info)
void ssygv 
(int itype, char jobz, char uplo, int n, float *sa, int 
lda, float *sb, int ldb, float *sw, int *info)

Arguments

ITYPE

Indicates the problem to be solved. Legal values for ITYPE are shown below. Any values not shown below are illegal.

1

Ax = Bx

2

ABx = x

3

BAx = x

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 and xB contain 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 and xB both contain the upper triangle.

'L' or 'l'

xA and xB both contain 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 matrix Z of eigenvectors normalized as shown below:

ITYPE

Eigenvectors stored in A

1 or 2

ZT × B × Z = I

3

ZT × B-1 × Z = I

If JOBZ = 'N' or 'n' and UPLO = 'U' or 'u' then the upper triangle of A including the diagonal is overwritten. If JOBZ = 'N' or 'n' and UPLO = 'L' or 'l' then the 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).

xB

On entry, the upper or lower triangle of the matrix B.
On exit, if UPLO = 'U' or 'u' then B contains the matrix U from the Cholesky factorization UTU of B. If UPLO = 'L' or 'l' then B contains the matrix L from the Cholesky factorization LLT of B.

LDB

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

xW

On exit, W(1:NFOUND) contains the computed 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.

0 < INFO N

Convergence failure.

INFO > N

The leading minor of order i of B, where i = INFO-N, is not positive definite.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           ITYPE, LDA, LDB, LDWORK, N
      PARAMETER        (ITYPE = 1)
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDB = N)
      PARAMETER        (LDWORK = 3 * N - 1)
C
      DOUBLE PRECISION  A(LDA,N), B(LDB,N), EVALS(N), WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DSYGV
      INTRINSIC         ABS
C
C     Initialize the array A to store the matrix A shown below.
C     Initialize the array B to store the matrix B shown below.
C
C         12  0  4        6  0  2
C     A =  0  6  0    b = 0  2  0
C          4  0  4        2  0  2
C
      DATA A / 1.2D1, 8D8, 8D8, 0.0D0, 6.0D0, 8D8, 4.0D0, 0.0D0,
     $         4.0D0 /
      DATA B / 6.0D0, 8D8, 8D8, 0.0D0, 2.0D0, 8D8, 2.0D0, 0.0D0,
     $         2.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, LDA
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  110 CONTINUE
      PRINT 1030
      DO 120, IROW = 1, N
        PRINT 1010, (B(ICOL,IROW), ICOL = 1, IROW - 1),
     $              (B(IROW,ICOL), ICOL = IROW, N)
  120 CONTINUE
      PRINT 1040
      DO 130, IROW = 1, LDB
        PRINT 1010, (B(IROW,ICOL), ICOL = 1, N)
  130 CONTINUE
C
      CALL DSYGV (ITYPE, 'VALUES AND EIGENVECTORS',
     $            'UPPER TRIANGLE OF A AND B STORED', N, A, LDA,
     $            B, LDB, EVALS, WORK, LDWORK, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1050, ABS(INFO)
        STOP 1
      ELSE IF (INFO .GT. N) THEN
        PRINT 1060, INFO
        STOP 2
      ELSE IF (INFO .GT. 0) THEN
        PRINT 1070, INFO
        STOP 3
      END IF
C
C     Print the eigenvalues and eigenvectors.
C
      PRINT 1080
      DO 140, IROW = 1, N
        PRINT 1090, EVALS(IROW), (A(IROW,ICOL), ICOL = 1, N)
  140 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, 'B in full form:')
 1040 FORMAT (/1X, 'B in symmetric form:  (* in unused elements)')
 1050 FORMAT (/1X, 'Illegal argument to DSYGV, argument #', I2)
 1060 FORMAT (/1X, 'B is not positive definite, INFO = ', I2)
 1070 FORMAT (/1X, 'Convergence failure, INFO = ', I2)
 1080 FORMAT (/1X, 'Eigenvalue', 6X, 'Eigenvector**T')
 1090 FORMAT (1X, F7.2, 6X, '[', 2(F5.3, ', '), F5.3, ']')
C
      END
 

Sample Output

 
 A in full form:
   12.0    0.0    4.0
    0.0    6.0    0.0
    4.0    0.0    4.0



 A in symmetric form:  (* in unused elements)
   12.0    0.0    4.0
   ****    6.0    0.0
   ****   ****    4.0



 B in full form:
    6.0    0.0    2.0
    0.0    2.0    0.0
    2.0    0.0    2.0



 B in symmetric form:  (* in unused elements)
    6.0    0.0    2.0
   ****    2.0    0.0
   ****   ****    2.0



 Eigenvalue      Eigenvector**T
    2.00      [-.085, -.493, 0.000]
    2.00      [0.000, 0.000, 0.707]
    3.00      [-.612, 0.612, 0.000]






Previous Next Contents Generated Index Doc Set Home