PROGRAM f08yyfe ! F08YYF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : f06bnf, f06uaf, nag_wp, x02ajf, ztgevc, ztgsna ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: eps, snorm, stnrm, tnorm INTEGER :: i, info, lda, ldb, ldvl, ldvr, & lwork, m, n ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: a(:,:), b(:,:), vl(:,:), vr(:,:), & work(:) REAL (KIND=nag_wp), ALLOCATABLE :: dif(:), rwork(:), s(:) INTEGER, ALLOCATABLE :: iwork(:) LOGICAL :: select(1) ! .. Executable Statements .. WRITE (nout,*) 'F08YYF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) READ (nin,*) n lda = n ldb = n ldvl = n ldvr = n lwork = 2*n*n ALLOCATE (a(lda,n),b(ldb,n),vl(ldvl,n),vr(ldvr,n),work(lwork),dif(n), & rwork(2*n),s(n),iwork(n+2)) ! Read A and B from data file READ (nin,*) (a(i,1:n),i=1,n) READ (nin,*) (b(i,1:n),i=1,n) ! Calculate the left and right generalized eigenvectors of the ! pair (A,B). ! The NAG name equivalent of ztgevc is f08yxf CALL ztgevc('Both','All',select,n,a,lda,b,ldb,vl,ldvl,vr,ldvr,n,m,work, & rwork,info) ! Estimate condition numbers for all the generalized eigenvalues ! and right eigenvectors of the pair (A,B) ! The NAG name equivalent of ztgsna is f08yyf CALL ztgsna('Both','All',select,n,a,lda,b,ldb,vl,ldvl,vr,ldvr,s,dif,n, & m,work,lwork,iwork,info) ! Print condition numbers of eigenvalues and right eigenvectors WRITE (nout,*) 'S' WRITE (nout,99999) s(1:m) WRITE (nout,*) WRITE (nout,*) 'DIF' WRITE (nout,99999) dif(1:m) ! Calculate approximate error estimates ! Compute the 1-norms of A and B and then compute ! SQRT(snorm**2 + tnorm**2) eps = x02ajf() snorm = f06uaf('1-norm',n,n,a,lda,rwork) tnorm = f06uaf('1-norm',n,n,b,ldb,rwork) stnrm = f06bnf(snorm,tnorm) WRITE (nout,*) WRITE (nout,*) 'Approximate error estimates for eigenvalues of (A,B)' WRITE (nout,99999) (eps*stnrm/s(i),i=1,m) WRITE (nout,*) WRITE (nout,*) & 'Approximate error estimates for right eigenvectors of (A,B)' WRITE (nout,99999) (eps*stnrm/dif(i),i=1,m) 99999 FORMAT ((3X,1P,7E11.1)) END PROGRAM f08yyfe