* F08PPF 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, LWORK PARAMETER (LDA=NMAX,LDVS=NMAX,LWORK=NMAX*(NB+1+NMAX/2)) * .. Local Scalars .. DOUBLE PRECISION ANORM, EPS, RCONDE, RCONDV, TOL INTEGER I, IFAIL, INFO, J, LWKOPT, N, SDIM * .. Local Arrays .. COMPLEX *16 A(LDA,NMAX), VS(LDVS,NMAX), W(NMAX), WORK(LWORK) DOUBLE PRECISION RWORK(NMAX) LOGICAL BWORK(NMAX) * .. External Functions .. DOUBLE PRECISION F06UAF, X02AJF LOGICAL SELECT EXTERNAL F06UAF, X02AJF, SELECT * .. External Subroutines .. EXTERNAL X04DAF, ZGEESX * .. Executable Statements .. WRITE (NOUT,*) 'F08PPF 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 = F06UAF('Frobenius',N,N,A,LDA,RWORK) * * Find the Schur factorization of A * CALL ZGEESX('Vectors (Schur)','Sort',SELECT, + 'Both reciprocal condition numbers',N,A,LDA,SDIM,W, + VS,LDVS,RCONDE,RCONDV,WORK,LWORK,RWORK,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 X04DAF('General',' ',N,N,A,LDA,'Schur matrix T',IFAIL) * WRITE (NOUT,*) CALL X04DAF('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 ZGEESX. 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(W) * .. Scalar Arguments .. * * Logical function SELECT for use with ZGEESX (F08PPF) * * Returns the value .TRUE. if the real part of the eigenvalue * W is positive. * COMPLEX *16 W * .. Local Scalars .. LOGICAL D * .. Intrinsic Functions .. INTRINSIC DBLE * .. Executable Statements .. IF (DBLE(W).GT.0.0D0) THEN D = .TRUE. ELSE D = .FALSE. END IF * SELECT = D * RETURN END