PROGRAM f08qgfe ! F08QGF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : dgemm, dtrsen, nag_wp, x04caf ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: alpha, beta, s, sep INTEGER :: i, ifail, info, lda, ldc, ldq, ldt, & liwork, lwork, m, n ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: a(:,:), c(:,:), q(:,:), t(:,:), & wi(:), work(:), wr(:) INTEGER, ALLOCATABLE :: iwork(:) LOGICAL, ALLOCATABLE :: select(:) ! .. Executable Statements .. WRITE (nout,*) 'F08QGF Example Program Results' WRITE (nout,*) FLUSH (nout) ! Skip heading in data file READ (nin,*) READ (nin,*) n lda = n ldc = n ldq = n ldt = n liwork = (n*n)/4 lwork = (n*n)/2 ALLOCATE (a(lda,n),c(ldc,n),q(ldq,n),t(ldt,n),wi(n),work(lwork),wr(n), & iwork(liwork),select(n)) ! Read T, Q and the logical array SELECT from data file READ (nin,*) (t(i,1:n),i=1,n) READ (nin,*) (q(i,1:n),i=1,n) READ (nin,*) select(1:n) ! Compute Q * T * Q**T to find A alpha = 1._nag_wp beta = 0._nag_wp CALL dgemm('N','N',n,n,n,alpha,q,ldq,t,ldt,beta,c,ldc) CALL dgemm('N','T',n,n,n,alpha,c,ldc,q,ldq,beta,a,lda) ! Print Matrix A, as computed from Q * T * Q**T ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL x04caf('General',' ',n,n,a,lda,'Matrix A computed from Q*T*Q^T', & ifail) WRITE (nout,*) FLUSH (nout) ! Reorder the Schur factor T and update the matrix Q to obtain TT and QT ! The NAG name equivalent of dtrsen is f08qgf CALL dtrsen('Both','Vectors',select,n,t,ldt,q,ldq,wr,wi,m,s,sep,work, & lwork,iwork,liwork,info) ! Compute QT * TT * QT**T to find A alpha = 1._nag_wp beta = 0._nag_wp CALL dgemm('N','N',n,n,n,alpha,q,ldq,t,ldt,beta,c,ldc) CALL dgemm('N','T',n,n,n,alpha,c,ldc,q,ldq,beta,a,lda) ! Print Matrix A, as computed from QT * TT * QT**T ifail = 0 CALL x04caf('General',' ',n,n,a,lda,'Matrix A computed from QT*TT*QT^T' & ,ifail) ! Print Result WRITE (nout,*) WRITE (nout,99999) 'Condition number estimate', & ' of the selected cluster of eigenvalues = ', 1.0E0_nag_wp/s WRITE (nout,*) WRITE (nout,99999) 'Condition number estimate of the spec', & 'ified invariant subspace = ', 1.0E0_nag_wp/sep 99999 FORMAT (1X,A,A,1P,E10.2) END PROGRAM f08qgfe