* F08PBF Example Program Text * Mark 21. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NB, NMAX PARAMETER (NB=64,NMAX=10) INTEGER LDA, LDVS, LIWORK, LWORK PARAMETER (LDA=NMAX,LDVS=NMAX,LIWORK=(NMAX*NMAX)/4, + LWORK=NMAX*(NB+2+NMAX/2)) * .. Local Scalars .. DOUBLE PRECISION ANORM, EPS, RCONDE, RCONDV, TOL INTEGER I, IFAIL, INFO, J, LWKOPT, N, SDIM * .. Local Arrays .. DOUBLE PRECISION A(LDA,NMAX), VS(LDVS,NMAX), WI(NMAX), + WORK(LWORK), WR(NMAX) INTEGER IWORK(LIWORK) LOGICAL BWORK(NMAX) * .. External Functions .. DOUBLE PRECISION F06RAF, X02AJF LOGICAL SELECT EXTERNAL F06RAF, X02AJF, SELECT * .. External Subroutines .. EXTERNAL DGEESX, X04CAF * .. Executable Statements .. WRITE (NOUT,*) 'F08PBF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N IF (N.LE.NMAX) THEN * * Read in the matrix A * READ (NIN,*) ((A(I,J),J=1,N),I=1,N) * * Find the Frobenius norms of A * ANORM = F06RAF('Frobenius',N,N,A,LDA,WORK) * * Find the Schur factorization of A * CALL DGEESX('Vectors (Schur)','Sort',SELECT, + 'Both reciprocal condition numbers',N,A,LDA,SDIM, + WR,WI,VS,LDVS,RCONDE,RCONDV,WORK,LWORK,IWORK, + LIWORK,BWORK,INFO) LWKOPT = WORK(1) * IF (INFO.EQ.0 .OR. INFO.EQ.(N+2)) THEN * * Print solution * WRITE (NOUT,99999) + 'Number of eigenvalues for which SELECT is true = ', SDIM, + '(dimension of invariant subspace)' WRITE (NOUT,*) IF (INFO.EQ.(N+2)) THEN WRITE (NOUT,99998) '***Note that rounding errors mean ', + 'that leading eigenvalues in the Schur form', + 'no longer satisfy SELECT = .TRUE.' WRITE (NOUT,*) END IF * * Print out factors of the Schur factorization * IFAIL = 0 CALL X04CAF('General',' ',N,N,A,LDA,'Schur matrix T',IFAIL) * WRITE (NOUT,*) CALL X04CAF('General',' ',N,N,VS,LDVS, + 'Matrix of Schur vectors Z',IFAIL) * * Print out the reciprocal condition numbers * WRITE (NOUT,*) WRITE (NOUT,99997) + 'Reciprocal of projection norm onto the invariant', + 'subspace for the selected eigenvalues', 'RCONDE = ', + RCONDE WRITE (NOUT,*) WRITE (NOUT,99996) + 'Reciprocal condition number for the invariant subspace', + 'RCONDV = ', RCONDV * * Compute the machine precision * EPS = X02AJF() TOL = EPS*ANORM * * Print out the approximate asymptotic error bound on the * average absolute error of the selected eigenvalues given by * * eps*norm(A)/RCONDE * WRITE (NOUT,*) WRITE (NOUT,99995) + 'Approximate asymptotic error bound for selected ', + 'eigenvalues = ', TOL/RCONDE * * Print out an approximate asymptotic bound on the maximum * angular error in the computed invariant subspace given by * * eps*norm(A)/RCONDV * WRITE (NOUT,99995) + 'Approximate asymptotic error bound for the invariant ', + 'subspace = ', TOL/RCONDV ELSE WRITE (NOUT,99994) 'Failure in DGEESX. INFO =', INFO END IF * * Print workspace information * IF (LWORK.LT.LWKOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99993) 'Optimum workspace required = ', LWKOPT, + 'Workspace provided = ', LWORK END IF ELSE WRITE (NOUT,*) WRITE (NOUT,*) 'NMAX too small' END IF STOP * 99999 FORMAT (1X,A,I4,/1X,A) 99998 FORMAT (1X,2A,/1X,A) 99997 FORMAT (1X,A,/1X,A,/1X,A,1P,E8.1) 99996 FORMAT (1X,A,/1X,A,1P,E8.1) 99995 FORMAT (1X,2A,1P,E8.1) 99994 FORMAT (1X,A,I4) 99993 FORMAT (1X,A,I5,/1X,A,I5) END LOGICAL FUNCTION SELECT(WR,WI) * .. Scalar Arguments .. * * Logical function SELECT for use with DGEESX (F08PBF) * * Returns the value .TRUE. if the imaginary part of the eigenvalue * (WR + WI*i) is zero, i.e. the eigenvalue is real * DOUBLE PRECISION WI, WR * .. Local Scalars .. LOGICAL D * .. Executable Statements .. IF (WI.EQ.0.0D0) THEN D = .TRUE. ELSE D = .FALSE. END IF * SELECT = D * RETURN END