PROGRAM f08gnfe ! F08GNF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : nag_wp, x02ajf, zhpev ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 CHARACTER (1), PARAMETER :: uplo = 'U' ! .. Local Scalars .. REAL (KIND=nag_wp) :: eerrbd, eps INTEGER :: i, info, j, n ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: ap(:), work(:) COMPLEX (KIND=nag_wp) :: dummy(1,1) REAL (KIND=nag_wp), ALLOCATABLE :: rwork(:), w(:) ! .. Intrinsic Functions .. INTRINSIC abs, max ! .. Executable Statements .. WRITE (nout,*) 'F08GNF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) READ (nin,*) n ALLOCATE (ap((n*(n+1))/2),work(2*n-1),rwork(3*n-2),w(n)) ! Read the upper or lower triangular part of the matrix A from ! data file IF (uplo=='U') THEN READ (nin,*) ((ap(i+(j*(j-1))/2),j=i,n),i=1,n) ELSE IF (uplo=='L') THEN READ (nin,*) ((ap(i+((2*n-j)*(j-1))/2),j=1,i),i=1,n) END IF ! Solve the Hermitian eigenvalue problem ! The NAG name equivalent of zhpev is f08gnf CALL zhpev('No vectors',uplo,n,ap,w,dummy,1,work,rwork,info) IF (info==0) THEN ! Print solution WRITE (nout,*) 'Eigenvalues' WRITE (nout,99999) w(1:n) ! Get the machine precision, EPS and compute the approximate ! error bound for the computed eigenvalues. Note that for ! the 2-norm, max( abs(W(i)) ) = norm(A), and since the ! eigenvalues are returned in ascending order ! max( abs(W(i)) ) = max( abs(W(1)), abs(W(n))) eps = x02ajf() eerrbd = eps*max(abs(w(1)),abs(w(n))) ! Print the approximate error bound for the eigenvalues WRITE (nout,*) WRITE (nout,*) 'Error estimate for the eigenvalues' WRITE (nout,99998) eerrbd ELSE WRITE (nout,99997) 'Failure in ZHPEV. INFO =', info END IF 99999 FORMAT (3X,(8F8.4)) 99998 FORMAT (4X,1P,6E11.1) 99997 FORMAT (1X,A,I4) END PROGRAM f08gnfe