* F08NPF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NB, NMAX PARAMETER (NB=64,NMAX=10) INTEGER LDA, LDVL, LDVR, LWORK PARAMETER (LDA=NMAX,LDVL=NMAX,LDVR=NMAX,LWORK=(NB+1)*NMAX) * .. Local Scalars .. DOUBLE PRECISION ABNRM, EPS, ERBND, RCND, TOL INTEGER I, IHI, ILO, INFO, J, LWKOPT, N * .. Local Arrays .. COMPLEX *16 A(LDA,NMAX), VL(LDVL,NMAX), VR(LDVR,NMAX), + W(NMAX), WORK(LWORK) DOUBLE PRECISION RCONDE(NMAX), RCONDV(NMAX), RWORK(2*NMAX), + SCALE(NMAX) * .. External Functions .. DOUBLE PRECISION X02AJF EXTERNAL X02AJF * .. External Subroutines .. EXTERNAL ZGEEVX * .. Executable Statements .. WRITE (NOUT,*) 'F08NPF Example Program Results' * Skip heading in data file READ (NIN,*) READ (NIN,*) N IF (N.LE.NMAX) THEN * * Read the matrix A from data file * READ (NIN,*) ((A(I,J),J=1,N),I=1,N) * * Solve the eigenvalue problem * CALL ZGEEVX('Balance','Vectors (left)','Vectors (right)', + 'Both reciprocal condition numbers',N,A,LDA,W,VL, + LDVL,VR,LDVR,ILO,IHI,SCALE,ABNRM,RCONDE,RCONDV, + WORK,LWORK,RWORK,INFO) * IF (INFO.EQ.0) THEN * * Compute the machine precision * EPS = X02AJF() TOL = EPS*ABNRM * * Print the eigenvalues and vectors, and associated condition * number and bounds * DO 20 J = 1, N * * Print information on jth eigenvalue * WRITE (NOUT,*) WRITE (NOUT,99999) 'Eigenvalue(', J, ') = ', W(J) RCND = RCONDE(J) WRITE (NOUT,*) WRITE (NOUT,99998) 'Reciprocal condition number = ', RCND IF (RCND.GT.0.0D0) THEN ERBND = TOL/RCND WRITE (NOUT,99998) 'Error bound = ', + ERBND ELSE WRITE (NOUT,*) 'Error bound is infinite' END IF * * Print information on jth eigenvector * WRITE (NOUT,*) WRITE (NOUT,99997) 'Eigenvector(', J, ')', + (VR(I,J),I=1,N) RCND = RCONDV(J) WRITE (NOUT,*) WRITE (NOUT,99998) 'Reciprocal condition number = ', RCND IF (RCND.GT.0.0D0) THEN ERBND = TOL/RCND WRITE (NOUT,99998) 'Error bound = ', + ERBND ELSE WRITE (NOUT,*) 'Error bound is infinite' END IF 20 CONTINUE ELSE WRITE (NOUT,*) WRITE (NOUT,99996) 'Failure in ZGEEVX. INFO =', INFO END IF * * Print workspace information * LWKOPT = WORK(1) IF (LWORK.LT.LWKOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99995) 'Optimum workspace required = ', LWKOPT, + 'Workspace provided = ', LWORK END IF ELSE WRITE (NOUT,*) WRITE (NOUT,*) 'NMAX too small' END IF STOP * 99999 FORMAT (1X,A,I2,A,'(',1P,E11.4,',',1P,E11.4,')') 99998 FORMAT (1X,A,1P,E8.1) 99997 FORMAT (1X,A,I2,A,/3(1X,'(',1P,E11.4,',',1P,E11.4,')',:)) 99996 FORMAT (1X,A,I4) 99995 FORMAT (1X,A,I5,/1X,A,I5) END