PROGRAM f08yufe ! F08YUF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : nag_wp, x04dbf, ztgsen ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: pl, pr INTEGER :: i, ifail, ijob, info, lda, ldb, ldq, & ldz, liwork, lwork, m, n LOGICAL :: wantq, wantz ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: a(:,:), alpha(:), b(:,:), & beta(:), q(:,:), work(:), z(:,:) REAL (KIND=nag_wp) :: dif(2) INTEGER, ALLOCATABLE :: iwork(:) LOGICAL, ALLOCATABLE :: select(:) CHARACTER (1) :: clabs(1), rlabs(1) ! .. Executable Statements .. WRITE (nout,*) 'F08YUF Example Program Results' WRITE (nout,*) FLUSH (nout) ! Skip heading in data file READ (nin,*) READ (nin,*) n lda = n ldb = n ldq = n ldz = n liwork = (n*n)/2 + 2 lwork = n*n ALLOCATE (a(lda,n),alpha(n),b(ldb,n),beta(n),q(ldq,n),work(lwork), & z(ldz,n),iwork(liwork),select(n)) ! Read A, B, Q, Z and the logical array SELECT from data file READ (nin,*) (a(i,1:n),i=1,n) READ (nin,*) (b(i,1:n),i=1,n) READ (nin,*) (q(i,1:n),i=1,n) READ (nin,*) (z(i,1:n),i=1,n) READ (nin,*) select(1:n) ! Set ijob, wantq and wantz ijob = 4 wantq = .TRUE. wantz = .TRUE. ! Reorder the Schur factors A and B and update the matrices ! Q and Z ! The NAG name equivalent of ztgsen is f08yuf CALL ztgsen(ijob,wantq,wantz,select,n,a,lda,b,ldb,alpha,beta,q,ldq,z, & ldz,m,pl,pr,dif,work,lwork,iwork,liwork,info) IF (info/=0) THEN WRITE (nout,99999) info WRITE (nout,*) FLUSH (nout) END IF ! Print reordered generalized Schur form ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL x04dbf('General',' ',n,n,a,lda,'Bracketed','F7.4', & 'Reordered Schur matrix A','Integer',rlabs,'Integer',clabs,80,0, & ifail) WRITE (nout,*) FLUSH (nout) ifail = 0 CALL x04dbf('General',' ',n,n,b,ldb,'Bracketed','F7.4', & 'Reordered Schur matrix B','Integer',rlabs,'Integer',clabs,80,0, & ifail) ! Print deflating subspaces WRITE (nout,*) FLUSH (nout) ifail = 0 CALL x04dbf('General',' ',n,m,q,ldq,'Bracketed','F7.4', & 'Basis of left deflating invariant subspace','Integer',rlabs, & 'Integer',clabs,80,0,ifail) WRITE (nout,*) FLUSH (nout) ifail = 0 CALL x04dbf('General',' ',n,m,z,ldz,'Bracketed','F7.4', & 'Basis of right deflating invariant subspace','Integer',rlabs, & 'Integer',clabs,80,0,ifail) ! Print norm estimates and F-norm upper bounds WRITE (nout,*) WRITE (nout,99998) 'Norm estimate of projection onto', & ' left eigenspace for selected cluster', 1.0E0_nag_wp/pl WRITE (nout,*) WRITE (nout,99998) 'Norm estimate of projection onto', & ' right eigenspace for selected cluster', 1.0E0_nag_wp/pr WRITE (nout,*) WRITE (nout,99998) 'F-norm based upper bound on', ' Difu', dif(1) WRITE (nout,*) WRITE (nout,99998) 'F-norm based upper bound on', ' Difl', dif(2) 99999 FORMAT (' Reordering could not be completed. INFO = ',I3) 99998 FORMAT (1X,2A/1X,1P,E10.2) END PROGRAM f08yufe