PROGRAM f08jyfe ! F08JYF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : nag_wp, x04daf, zstegr ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. REAL (KIND=nag_wp), PARAMETER :: vl = 0.0E0_nag_wp REAL (KIND=nag_wp), PARAMETER :: vu = 0.0E0_nag_wp INTEGER, PARAMETER :: il = 0, iu = 0, nin = 5, nout = 6 CHARACTER (1), PARAMETER :: range = 'A' ! .. Local Scalars .. REAL (KIND=nag_wp) :: abstol INTEGER :: i, ifail, info, ldz, liwork, lwork, & m, n CHARACTER (1) :: jobz ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: z(:,:) REAL (KIND=nag_wp), ALLOCATABLE :: d(:), e(:), w(:), work(:) INTEGER, ALLOCATABLE :: isuppz(:), iwork(:) ! .. Executable Statements .. WRITE (nout,*) 'F08JYF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) READ (nin,*) n ldz = n liwork = 10*n lwork = 18*n ALLOCATE (z(ldz,n),d(n),e(n),w(n),work(lwork),isuppz(2*n), & iwork(liwork)) ! Read the symmetric tridiagonal matrix T from data file, first ! the diagonal elements, then the off diagonal elements and then ! JOBV ('N' - eigenvalues only, 'V' - vectors as well) READ (nin,*) d(1:n) READ (nin,*) e(1:n-1) READ (nin,*) jobz ! Calculate all the eigenvalues of T. Set ABSTOL to zero so that ! the default value is used. abstol = 0.0E0_nag_wp ! The NAG name equivalent of zstegr is f08jyf CALL zstegr(jobz,range,n,d,e,vl,vu,il,iu,abstol,m,w,z,ldz,isuppz,work, & lwork,iwork,liwork,info) IF (info==0) THEN ! Print eigenvalues and eigenvectors WRITE (nout,*) 'Eigenvalues' WRITE (nout,99999) w(1:m) WRITE (nout,*) FLUSH (nout) ! Normalize the eigenvectors DO i = 1, m z(1:n,i) = z(1:n,i)/z(1,i) END DO ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 CALL x04daf('General',' ',n,m,z,ldz,'Eigenvectors',ifail) ELSE WRITE (nout,99998) 'Failure to compute an eigenvalue, INFO = ', info END IF 99999 FORMAT ((3X,8F8.4)) 99998 FORMAT (1X,A,I10) END PROGRAM f08jyfe