*     F08QYF Example Program Text
*     Mark 21 Release. NAG Copyright 2004.
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          NMAX
      PARAMETER        (NMAX=8)
      INTEGER          LDT, LDWORK, LDVL, LDVR
      PARAMETER        (LDT=NMAX,LDWORK=NMAX,LDVL=NMAX,LDVR=NMAX)
*     .. Local Scalars ..
      DOUBLE PRECISION EPS, TNORM
      INTEGER          I, INFO, J, M, N
*     .. Local Arrays ..
      COMPLEX *16      T(LDT,NMAX), VL(LDVL,NMAX), VR(LDVR,NMAX),
     +                 WORK(LDWORK,NMAX+1)
      DOUBLE PRECISION RWORK(NMAX), S(NMAX), SEP(NMAX)
      LOGICAL          SELECT(1)
*     .. External Functions ..
      DOUBLE PRECISION F06UAF, X02AJF
      EXTERNAL         F06UAF, X02AJF
*     .. External Subroutines ..
      EXTERNAL         ZTREVC, ZTRSNA
*     .. Executable Statements ..
      WRITE (NOUT,*) 'F08QYF Example Program Results'
      WRITE (NOUT,*)
*     Skip heading in data file
      READ (NIN,*)
      READ (NIN,*) N
      IF (N.LE.NMAX) THEN
*
*        Read T from data file
*
         READ (NIN,*) ((T(I,J),J=1,N),I=1,N)
*
*        Calculate the left and right eigenvectors of T
*
         CALL ZTREVC('Both','All',SELECT,N,T,LDT,VL,LDVL,VR,LDVR,N,M,
     +               WORK,RWORK,INFO)
*
*        Estimate condition numbers for all the eigenvalues and right
*        eigenvectors of T
*
         CALL ZTRSNA('Both','All',SELECT,N,T,LDT,VL,LDVL,VR,LDVR,S,SEP,
     +               N,M,WORK,LDWORK,RWORK,INFO)
*
*        Print condition numbers of eigenvalues and right eigenvectors
*
         WRITE (NOUT,*) 'S'
         WRITE (NOUT,99999) (S(I),I=1,M)
         WRITE (NOUT,*)
         WRITE (NOUT,*) 'SEP'
         WRITE (NOUT,99999) (SEP(I),I=1,M)
*
*        Calculate approximate error estimates (using the 1-norm)
*
         EPS = X02AJF()
         TNORM = F06UAF('1-norm',N,N,T,LDT,RWORK)
         WRITE (NOUT,*)
         WRITE (NOUT,*) 'Approximate error estimates for eigenvalues ',
     +     'of T (machine-dependent)'
         WRITE (NOUT,99999) (EPS*TNORM/S(I),I=1,M)
         WRITE (NOUT,*)
         WRITE (NOUT,*) 'Approximate error estimates for right ',
     +     'eigenvectors of T (machine-dependent)'
         WRITE (NOUT,99999) (EPS*TNORM/SEP(I),I=1,M)
      ELSE
         WRITE (NOUT,*) 'NMAX too small'
      END IF
      STOP
*
99999 FORMAT ((3X,1P,7D11.1))
      END
