Previous Next Contents Generated Index Doc Set Home



Generalized Eigenvalues and Eigenvectors for Symmetric Matrices in Packed Storage

The subroutines in this section compute the generalized eigenvalues (, ) for a pair of symmetric matrices A and B in packed storage. 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)Tx = 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 DSPGV 
(ITYPE, JOBZ, UPLO, N, DA, DB, DW, DZ, LDZ, DWORK, 
INFO)
CALL SSPGV 
(ITYPE, JOBZ, UPLO, N, SA, SB, SW, SZ, LDZ, SWORK, 
INFO)






void dspgv 
(int itype, char jobz, char uplo, int n, double *da, 
double *db, double *dw, double *dz, int ldz, int *info)
void sspgv 
(int itype, char jobz, char uplo, int n, float *sa, 
float *sb, float *sw, float *sz, int ldz, 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.
The dimension of xA is (N × N + N) / 2.
On exit, A is overwritten.

xB

On entry, the upper or lower triangle of the matrix B. The dimension of xB is (N × N + N) / 2.
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.

xW

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

xZ

On exit, if JOBZ = 'V' or 'v' then xZ contains the matrix Z of eigenvectors normalized as shown below:

ITYPE

Eigenvectors stored in Z

1 or 2

ZT × B × Z = I

3

ZT × B-1 × Z = I

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 3 × N.

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, LDEVEC, LDWORK, LENGTA, LENGTB, N
      PARAMETER        (ITYPE = 1)
      PARAMETER        (N = 3)
      PARAMETER        (LDEVEC = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LENGTA = (N * N + N) / 2)
      PARAMETER        (LENGTB = (N * N + N) / 2)
C
      DOUBLE PRECISION  A(LENGTA), B(LENGTB), EVALS(N)
      DOUBLE PRECISION  EVECS(LDEVEC,N), WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DSPGV
      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, 0.0D0, 6.0D0, 4.0D0, 0.0D0, 4.0D0 /
      DATA B / 6.0D0, 0.0D0, 2.0D0, 2.0D0, 0.0D0, 2.0D0 /
C
C     Print the initial value of the arrays.
C
      PRINT 1000
      PRINT 1010, A(1), A(2), A(4)
      PRINT 1010, A(2), A(3), A(5)
      PRINT 1010, A(4), A(5), A(6)
      PRINT 1020
      PRINT 1010, B(1), B(2), B(4)
      PRINT 1010, B(2), B(3), B(5)
      PRINT 1010, B(4), B(5), B(6)
C
      CALL DSPGV (ITYPE, 'VALUES AND EIGENVECTORS',
     $            'UPPER TRIANGLES OF A AND B STORED', N, A, B,
     $            EVALS, EVECS, LDEVEC, WORK, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1030, ABS(INFO)
        STOP 1
      ELSE IF (INFO .GT. N) THEN
        PRINT 1040, INFO
        STOP 2
      ELSE IF (INFO .GT. 0) THEN
        PRINT 1050, INFO
        STOP 3
      END IF
C
C     Print the eigenvalues and eigenvectors.
C
      PRINT 1060
      DO 140, IROW = 1, N
        PRINT 1070, EVALS(IROW), (EVECS(IROW,ICOL), ICOL = 1, N)
  140 CONTINUE
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (3(3X, F4.1))
 1020 FORMAT (/1X, 'B:')
 1030 FORMAT (/1X, 'Illegal argument to DSPGV, argument #', I2)
 1040 FORMAT (/1X, 'B is not positive definite, INFO = ', I2)
 1050 FORMAT (/1X, 'Convergence failure, INFO = ', I2)
 1060 FORMAT (/1X, 'Eigenvalue', 6X, 'Eigenvector**T')
 1070 FORMAT (1X, F7.2, 6X, '[', 2(F5.3, ', '), F5.3, ']')
C
      END
 

Sample Output

 
 A:
   12.0    0.0    4.0
    0.0    6.0    0.0
    4.0    0.0    4.0



 B:
    6.0    0.0    2.0
    0.0    2.0    0.0
    2.0    0.0    2.0



 Eigenvalue      Eigenvector**T
    2.00      [0.046, -.498, 0.000]
    2.00      [0.000, 0.000, 0.707]
    3.00      [-.750, 0.433, 0.000]






Previous Next Contents Generated Index Doc Set Home