* F08JHF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER LGNMAX, NMAX, KDMAX PARAMETER (LGNMAX=5,NMAX=2**LGNMAX,KDMAX=8) INTEGER LDAB, LDQ, LIWORK, LWORK PARAMETER (LDAB=KDMAX+1,LDQ=NMAX, + LIWORK=6+6*NMAX+5*NMAX*LGNMAX, + LWORK=1+3*NMAX+2*NMAX*LGNMAX+3*NMAX*NMAX) CHARACTER UPLO PARAMETER (UPLO='U') * .. Local Scalars .. INTEGER I, IFAIL, INFO, J, KD, LIWOPT, LWOPT, N * .. Local Arrays .. DOUBLE PRECISION AB(LDAB,NMAX), D(NMAX), E(NMAX-1), Q(LDQ,NMAX), + WORK(LWORK) INTEGER IWORK(LIWORK) * .. External Subroutines .. EXTERNAL DSBTRD, DSTEDC, X04CAF * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. Executable Statements .. WRITE (NOUT,*) 'F08JHF 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 band matrix A * from data file * IF (UPLO.EQ.'U') THEN DO 20 I = 1, N READ (NIN,*) (AB(KD+1+I-J,J),J=I,MIN(N,I+KD)) 20 CONTINUE ELSE IF (UPLO.EQ.'L') THEN DO 40 I = 1, N READ (NIN,*) (AB(1+I-J,J),J=MAX(1,I-KD),I) 40 CONTINUE END IF * * Reduce A to tridiagonal form T = (Q**T)*A*Q, and form Q * CALL DSBTRD('V',UPLO,N,KD,AB,LDAB,D,E,Q,LDQ,WORK,INFO) * * Calculate all the eigenvalues and eigenvectors of A, * from T and Q * CALL DSTEDC('V',N,D,E,Q,LDQ,WORK,LWORK,IWORK,LIWORK,INFO) LWOPT = WORK(1) LIWOPT = IWORK(1) * IF (INFO.EQ.0) THEN * * Print eigenvalues and eigenvectors * WRITE (NOUT,*) 'Eigenvalues' WRITE (NOUT,99999) (D(I),I=1,N) * WRITE (NOUT,*) IFAIL = 0 CALL X04CAF('General',' ',N,N,Q,LDQ,'Eigenvectors',IFAIL) * ELSE WRITE (NOUT,99998) 'Failure in DSTEDC. INFO = ', INFO END IF * * Print workspace information * IF (LWORK.LT.LWOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99997) 'Real workspace required = ', LWOPT, + 'Real workspace provided = ', LWORK END IF IF (LIWORK.LT.LIWOPT) THEN WRITE (NOUT,*) WRITE (NOUT,99997) 'Integer workspace required = ', LIWOPT, + 'Integer workspace provided = ', LIWORK END IF ELSE WRITE (NOUT,*) 'NMAX and/or KDMAX too small' END IF STOP * 99999 FORMAT ((3X,8F8.4)) 99998 FORMAT (1X,A,I10) 99997 FORMAT ((1X,A,I5)) END