Previous Next Contents Generated Index Doc Set Home



Eigenvalues and Eigenvectors of a Symmetric Matrix in Packed Storage (Simple Driver)

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

Calling Sequence

CALL DSPEV 
(JOBZ, UPLO, N, DA, DW, DZ, LDZ, DWORK, INFO)
CALL SSPEV 
(JOBZ, UPLO, N, SA, SW, SZ, LDZ, SWORK, INFO)






void dspev 
(char jobz, char uplo, int n, double *da, double *dw, 
double *dz, int ldz, int *info)
void sspev 
(char jobz, char uplo, int n, float *sa, float *sw, 
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.

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.
The dimension of xA is (N × N + N) / 2.
On exit, A is overwritten.

xW

On exit, the N eigenvalues in ascending order.

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

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, LENGTA, N
      PARAMETER        (N = 3)
      PARAMETER        (LDEVEC = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LENGTA = (N * (N + 1)) / 2)
C
      DOUBLE PRECISION  A(LENGTA), EVALS(N), EVECS(LDEVEC,N)
      DOUBLE PRECISION  WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DSPEV
      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, 1.0D0, 9.0D0, 1.0D0, 1.0D0, 9.0D0 /
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)
C
C     Compute the eigenvalues and eigenvectors of A.
C
      CALL DSPEV ('VALUES AND VECTORS', 'UPPER TRIANGULAR A', N,
     $            A, EVALS, 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, EVALS(ICOL), (EVECS(IROW,ICOL), IROW = 1, N)
  120 CONTINUE
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (3(3X, F4.1))
 1020 FORMAT (/1X, 'Illegal argument to DSPEV, argument #', I2)
 1030 FORMAT (/1X, 'Convergence failure, INFO = ', I2)
 1040 FORMAT (/1X, 'Eigenvalue', 4X, 'Eigenvector**T')
 1050 FORMAT (1X, F7.2, 5X, '[', F4.2, ', ', F4.2, ', ', 
     $        F4.2, ']')
C
      END
 

Sample Output

 
 A:
    9.0    1.0    1.0
    1.0    9.0    1.0
    1.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