
PROGRAM TEST

IMPLICIT NONE

C

INTEGER LDEVEC, LDIWRK, LDWORK, LENGTA, N

PARAMETER (N = 3)

PARAMETER (LDEVEC = N)

PARAMETER (LDIWRK = 5 * N)

PARAMETER (LDWORK = 8 * N)

PARAMETER (LENGTA = (N * N + N) / 2)

C

DOUBLE PRECISION A(LENGTA), TEMP, EVALS(N), EVECS(LDEVEC,N)

DOUBLE PRECISION WORK(LDWORK)

INTEGER ICOL, IFAIL(N), INFO, IROW, ITEMP

INTEGER IWORK(LDIWRK), NFOUND

C

EXTERNAL DSYEVX

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

C Arguments 6  9 are not used because RANGE (argument 2)

C indicates that all eigenvalues should be found. Note

C however that the scratch values passed into DSPEVX for

C arguments 6  9 are of the correct type. Arguments 6 and 7

C take the place of double precision values, so TEMP is

C declared double precision. Arguments 8 and 9 take the place

C of integer arguments, so ITEMP is declared integer. Even

C though these arguments are not referenced, passing arguments

C of the wrong type may cause run time errors due to the

C alignment of the arguments in memory.

C

CALL DSPEVX ('VALUES AND VECTORS', 'ALL EIGENVALUES',

$ 'UPPER TRIANGULAR A', N, A, TEMP, TEMP, ITEMP,

$ ITEMP, 0.0D0, NFOUND, EVALS, EVECS, LDEVEC,

$ WORK, IWORK, IFAIL, 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 DSPEVX, 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

