* F08JBF Example Program Text * Mark 21. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, MMAX PARAMETER (NMAX=20,MMAX=10) INTEGER LDZ PARAMETER (LDZ=NMAX) * .. Local Scalars .. DOUBLE PRECISION ABSTOL, VL, VU INTEGER I, IFAIL, IL, INFO, IU, J, M, N * .. Local Arrays .. DOUBLE PRECISION D(NMAX), E(NMAX), W(NMAX), WORK(5*NMAX), + Z(LDZ,MMAX) INTEGER INDEX(NMAX), IWORK(5*NMAX) * .. External Functions .. DOUBLE PRECISION X02AMF EXTERNAL X02AMF * .. External Subroutines .. EXTERNAL DSTEVX, X04CAF * .. Executable Statements .. WRITE (NOUT,*) 'F08JBF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N IF (N.LE.NMAX) THEN * * Read the lower and upper bounds of the interval to be searched, * and read the diagonal and off-diagonal elements of the matrix * A from data file * READ (NIN,*) VL, VU READ (NIN,*) (D(I),I=1,N) READ (NIN,*) (E(I),I=1,N-1) * * Set the absolute error tolerance for eigenvalues. With ABSTOL * set to zero, the default value would be used instead * ABSTOL = 2*X02AMF() * * Solve the symmetric eigenvalue problem * CALL DSTEVX('Vectors','Values in range',N,D,E,VL,VU,IL,IU, + ABSTOL,M,W,Z,LDZ,WORK,IWORK,INDEX,INFO) * IF (INFO.GE.0 .AND. M.LE.MMAX) THEN * * Print solution * WRITE (NOUT,99999) 'Number of eigenvalues found =', M WRITE (NOUT,*) WRITE (NOUT,*) 'Eigenvalues' WRITE (NOUT,99998) (W(J),J=1,M) * IFAIL = 0 CALL X04CAF('General',' ',N,M,Z,LDZ,'Selected eigenvectors', + IFAIL) IF (INFO.GT.0) THEN WRITE (NOUT,99999) + 'INFO eigenvectors failed to converge, INFO =', INFO WRITE (NOUT,*) + 'Indices of eigenvectors that did not converge' WRITE (NOUT,99997) (INDEX(J),J=1,M) END IF ELSE IF (M.GT.MMAX) THEN WRITE (NOUT,99996) 'M greater than MMAX, M =', M, + ', MMAX =', MMAX ELSE WRITE (NOUT,99999) 'Failure in DSTEVX. INFO =', INFO END IF ELSE WRITE (NOUT,*) WRITE (NOUT,*) 'NMAX too small' END IF STOP * 99999 FORMAT (1X,A,I5) 99998 FORMAT (3X,(8F8.4)) 99997 FORMAT (3X,(8I8)) 99996 FORMAT (1X,A,I5,A,I5) END