* F08NGF Example Program Text * Mark 16 Release. NAG Copyright 1992. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, LDA, LDH, LDZ, LWORK, LDVL, LDVR PARAMETER (NMAX=8,LDA=NMAX,LDH=NMAX,LDZ=1,LWORK=64*NMAX, + LDVL=NMAX,LDVR=NMAX) * .. Local Scalars .. DOUBLE PRECISION THRESH INTEGER I, IFAIL, INFO, J, M, N * .. Local Arrays .. DOUBLE PRECISION A(LDA,NMAX), H(LDH,NMAX), TAU(NMAX), + VL(LDVL,NMAX), VR(LDVR,NMAX), WI(NMAX), + WORK(LWORK), WR(NMAX), Z(LDZ,1) INTEGER IFAILL(NMAX), IFAILR(NMAX) LOGICAL SELECT(NMAX) * .. External Subroutines .. EXTERNAL DGEHRD, DHSEIN, DHSEQR, DORMHR, F06QFF, X04CAF * .. Executable Statements .. WRITE (NOUT,*) 'F08NGF Example Program Results' * Skip heading in data file READ (NIN,*) READ (NIN,*) N IF (N.LE.NMAX) THEN * * Read A from data file * READ (NIN,*) ((A(I,J),J=1,N),I=1,N) * READ (NIN,*) THRESH * * Reduce A to upper Hessenberg form H = (Q**T)*A*Q * CALL DGEHRD(N,1,N,A,LDA,TAU,WORK,LWORK,INFO) * * Copy A to H * CALL F06QFF('General',N,N,A,LDA,H,LDH) * * Calculate the eigenvalues of H (same as A) * CALL DHSEQR('Eigenvalues','No vectors',N,1,N,H,LDH,WR,WI,Z,LDZ, + WORK,LWORK,INFO) * WRITE (NOUT,*) IF (INFO.GT.0) THEN WRITE (NOUT,*) 'Failure to converge.' ELSE WRITE (NOUT,*) 'Eigenvalues' WRITE (NOUT,99999) (' (',WR(I),',',WI(I),')',I=1,N) * DO 20 I = 1, N SELECT(I) = WR(I) .LT. THRESH 20 CONTINUE * * Calculate the eigenvectors of H (as specified by SELECT), * storing the result in VR * CALL DHSEIN('Right','QR','No initial vectors',SELECT,N,A, + LDA,WR,WI,VL,LDVL,VR,LDVR,N,M,WORK,IFAILL, + IFAILR,INFO) * * Calculate the eigenvectors of A = Q * (eigenvectors of H) * CALL DORMHR('Left','No transpose',N,M,1,N,A,LDA,TAU,VR,LDVR, + WORK,LWORK,INFO) * * Print eigenvectors * WRITE (NOUT,*) IFAIL = 0 * CALL X04CAF('General',' ',N,M,VR,LDVR, + 'Contents of array VR',IFAIL) * END IF END IF STOP * 99999 FORMAT (1X,A,F8.4,A,F8.4,A) END