* F08XPF 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, LDB, LDVSL, LDVSR, LIWORK, LWORK PARAMETER (LDA=NMAX,LDB=NMAX,LDVSL=NMAX,LDVSR=NMAX, + LIWORK=NMAX+2,LWORK=NMAX*NB+NMAX*NMAX/2) * .. Local Scalars .. DOUBLE PRECISION ABNORM, ANORM, BNORM, EPS, TOL INTEGER I, IFAIL, INFO, J, LWKOPT, N, SDIM * .. Local Arrays .. COMPLEX *16 A(LDA,NMAX), ALPHA(NMAX), B(LDB,NMAX), + BETA(NMAX), VSL(LDVSL,NMAX), VSR(LDVSR,NMAX), + WORK(LWORK) DOUBLE PRECISION RCONDE(2), RCONDV(2), RWORK(8*NMAX) INTEGER IWORK(LIWORK) LOGICAL BWORK(NMAX) CHARACTER CLABS(1), RLABS(1) * .. External Functions .. DOUBLE PRECISION F06BNF, F06UAF, X02AJF LOGICAL SELCTG EXTERNAL F06BNF, F06UAF, X02AJF, SELCTG * .. External Subroutines .. EXTERNAL X04DBF, ZGGESX * .. Executable Statements .. WRITE (NOUT,*) 'F08XPF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N IF (N.LE.NMAX) THEN * * Read in the matrices A and B * READ (NIN,*) ((A(I,J),J=1,N),I=1,N) READ (NIN,*) ((B(I,J),J=1,N),I=1,N) * * Find the Frobenius norms of A and B * ANORM = F06UAF('Frobenius',N,N,A,LDA,RWORK) BNORM = F06UAF('Frobenius',N,N,B,LDB,RWORK) * * Find the generalized Schur form * CALL ZGGESX('Vectors (left)','Vectors (right)','Sort',SELCTG, + 'Both reciprocal condition numbers',N,A,LDA,B,LDB, + SDIM,ALPHA,BETA,VSL,LDVSL,VSR,LDVSR,RCONDE,RCONDV, + WORK,LWORK,RWORK,IWORK,LIWORK,BWORK,INFO) * IF (INFO.GT.0 .AND. INFO.NE.(N+2)) THEN WRITE (NOUT,99999) 'Failure in ZGGESX. INFO =', INFO ELSE WRITE (NOUT,99999) + 'Number of eigenvalues for which SELCTG is true = ', SDIM, + '(dimension of deflating subspaces)' WRITE (NOUT,*) IF (INFO.EQ.(N+2)) THEN WRITE (NOUT,99998) '***Note that rounding errors mean ', + 'that leading eigenvalues in the generalized', + 'Schur form no longer satisfy SELCTG = .TRUE.' WRITE (NOUT,*) END IF * * Print out the factors of the generalized Schur factorization * IFAIL = 0 CALL X04DBF('General',' ',N,N,A,LDA,'Bracketed','F7.2', + 'Generalized Schur matrix S','Integer',RLABS, + 'Integer',CLABS,80,0,IFAIL) * WRITE (NOUT,*) CALL X04DBF('General',' ',N,N,B,LDB,'Bracketed','F7.2', + 'Generalized Schur matrix T','Integer',RLABS, + 'Integer',CLABS,80,0,IFAIL) * WRITE (NOUT,*) CALL X04DBF('General',' ',N,N,VSL,LDVSL,'Bracketed','F7.4', + 'Matrix of left generalized Schur vectors', + 'Integer',RLABS,'Integer',CLABS,80,0,IFAIL) * WRITE (NOUT,*) CALL X04DBF('General',' ',N,N,VSR,LDVSR,'Bracketed','F7.4', + 'Matrix of right generalized Schur vectors', + 'Integer',RLABS,'Integer',CLABS,80,0,IFAIL) * * Print out the reciprocal condition numbers * WRITE (NOUT,*) WRITE (NOUT,99997) + 'Reciprocals of left and right projection norms onto', + 'the deflating subspaces for the selected eigenvalues', + 'RCONDE(1) = ', RCONDE(1), ', RCONDE(2) = ', RCONDE(2) WRITE (NOUT,*) WRITE (NOUT,99997) + 'Reciprocal condition numbers for the left and right', + 'deflating subspaces', 'RCONDV(1) = ', RCONDV(1), + ', RCONDV(2) = ', RCONDV(2) * * Compute the machine precision and sqrt(ANORM**2+BNORM**2) * EPS = X02AJF() ABNORM = F06BNF(ANORM,BNORM) TOL = EPS*ABNORM * * Print out the approximate asymptotic error bound on the * average absolute error of the selected eigenvalues given by * * eps*norm((A, B))/PL, where PL = RCONDE(1) * WRITE (NOUT,*) WRITE (NOUT,99996) + 'Approximate asymptotic error bound for selected ', + 'eigenvalues = ', TOL/RCONDE(1) * * Print out an approximate asymptotic bound on the maximum * angular error in the computed deflating subspaces given by * * eps*norm((A, B))/DIF(2), where DIF(2) = RCONDV(2) * WRITE (NOUT,99996) + 'Approximate asymptotic error bound for the deflating ', + 'subspaces = ', TOL/RCONDV(2) * LWKOPT = WORK(1) IF (LWORK.LT.LWKOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99995) 'Optimum workspace required = ', + LWKOPT, 'Workspace provided = ', LWORK END IF 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,2(A,1P,E8.1)) 99996 FORMAT (1X,2A,1P,E8.1) 99995 FORMAT (1X,A,I5,/1X,A,I5) END LOGICAL FUNCTION SELCTG(A,B) * .. Scalar Arguments .. * * Logical function SELCTG for use with ZGGESX (F08XPF) * * Returns the value .TRUE. if the absolute value of the eigenvalue * A/B < 6.0 * COMPLEX *16 A, B * .. Local Scalars .. LOGICAL D * .. Intrinsic Functions .. INTRINSIC ABS * .. Executable Statements .. IF (ABS(A).LT.6.0D0*ABS(B)) THEN D = .TRUE. ELSE D = .FALSE. END IF * SELCTG = D * RETURN END