* F08HNF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, KDMAX PARAMETER (NMAX=20,KDMAX=5) INTEGER LDAB, LDZ PARAMETER (LDAB=KDMAX+1,LDZ=NMAX) CHARACTER UPLO PARAMETER (UPLO='U') * .. Local Scalars .. DOUBLE PRECISION EERRBD, EPS INTEGER I, IFAIL, INFO, J, KD, N * .. Local Arrays .. COMPLEX *16 AB(LDAB,NMAX), WORK(NMAX), Z(LDZ,NMAX) DOUBLE PRECISION RCONDZ(NMAX), RWORK(3*NMAX-2), W(NMAX), + ZERRBD(NMAX) * .. External Functions .. DOUBLE PRECISION X02AJF EXTERNAL X02AJF * .. External Subroutines .. EXTERNAL DDISNA, X04DAF, ZHBEV * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN * .. Executable Statements .. WRITE (NOUT,*) 'F08HNF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N, KD IF (N.LE.NMAX .AND. KD.LE.KDMAX) THEN * * Read the upper or lower triangular part of the symmetric band * matrix A from data file * IF (UPLO.EQ.'U') THEN READ (NIN,*) ((AB(KD+1+I-J,J),J=I,MIN(N,I+KD)),I=1,N) ELSE IF (UPLO.EQ.'L') THEN READ (NIN,*) ((AB(1+I-J,J),J=MAX(1,I-KD),I),I=1,N) END IF * * Solve the band Hermitian eigenvalue problem * CALL ZHBEV('Vectors',UPLO,N,KD,AB,LDAB,W,Z,LDZ,WORK,RWORK,INFO) * IF (INFO.EQ.0) THEN * * Print solution * WRITE (NOUT,*) 'Eigenvalues' WRITE (NOUT,99999) (W(J),J=1,N) * IFAIL = 0 CALL X04DAF('General',' ',N,N,Z,LDZ,'Eigenvectors',IFAIL) * * 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))) * * Call DDISNA (F08FLF) to estimate reciprocal condition * numbers for the eigenvectors * CALL DDISNA('Eigenvectors',N,N,W,RCONDZ,INFO) * * Compute the error estimates for the eigenvectors * DO 20 I = 1, N ZERRBD(I) = EERRBD/RCONDZ(I) 20 CONTINUE * * Print the approximate error bounds for the eigenvalues * and vectors * WRITE (NOUT,*) WRITE (NOUT,*) 'Error estimate for the eigenvalues' WRITE (NOUT,99998) EERRBD WRITE (NOUT,*) WRITE (NOUT,*) 'Error estimates for the eigenvectors' WRITE (NOUT,99998) (ZERRBD(I),I=1,N) ELSE WRITE (NOUT,99997) 'Failure in ZHBEV. INFO =', INFO END IF ELSE WRITE (NOUT,*) 'NMAX and/or KDMAX too small' END IF * 99999 FORMAT (3X,(8F8.4)) 99998 FORMAT (4X,1P,6E11.1) 99997 FORMAT (1X,A,I4) END