* F07HHF Example Program Text * Mark 15 Release. NAG Copyright 1991. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) DOUBLE PRECISION ZERO PARAMETER (ZERO=0.0D0) INTEGER NMAX, NRHMAX, KDMAX, LDAB, LDAFB, LDB, LDX PARAMETER (NMAX=8,NRHMAX=NMAX,KDMAX=8,LDAB=KDMAX+1, + LDAFB=KDMAX+1,LDB=NMAX,LDX=NMAX) * .. Local Scalars .. INTEGER I, IFAIL, INFO, J, KD, N, NRHS CHARACTER UPLO * .. Local Arrays .. DOUBLE PRECISION AB(LDAB,NMAX), AFB(LDAFB,NMAX), B(LDB,NRHMAX), + BERR(NRHMAX), FERR(NRHMAX), WORK(3*NMAX), + X(LDX,NMAX) INTEGER IWORK(NMAX) * .. External Subroutines .. EXTERNAL DPBRFS, DPBTRF, DPBTRS, F06QFF, F06QHF, X04CAF * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. Executable Statements .. WRITE (NOUT,*) 'F07HHF Example Program Results' * Skip heading in data file READ (NIN,*) READ (NIN,*) N, KD, NRHS IF (N.LE.NMAX .AND. KD.LE.KDMAX .AND. NRHS.LE.NRHMAX) THEN * * Set A to zero to avoid referencing uninitialized elements * CALL F06QHF('General',KD+1,N,ZERO,ZERO,AB,LDAB) * * Read A and B from data file, and copy A to AFB and B to X * READ (NIN,*) UPLO 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 READ (NIN,*) ((B(I,J),J=1,NRHS),I=1,N) * CALL F06QFF('General',KD+1,N,AB,LDAB,AFB,LDAFB) * CALL F06QFF('General',N,NRHS,B,LDB,X,LDX) * * Factorize A in the array AFB * CALL DPBTRF(UPLO,N,KD,AFB,LDAFB,INFO) * WRITE (NOUT,*) IF (INFO.EQ.0) THEN * * Compute solution in the array X * CALL DPBTRS(UPLO,N,KD,NRHS,AFB,LDAFB,X,LDX,INFO) * * Improve solution, and compute backward errors and * estimated bounds on the forward errors * CALL DPBRFS(UPLO,N,KD,NRHS,AB,LDAB,AFB,LDAFB,B,LDB,X,LDX, + FERR,BERR,WORK,IWORK,INFO) * * Print solution * IFAIL = 0 * CALL X04CAF('General',' ',N,NRHS,X,LDX,'Solution(s)',IFAIL) * WRITE (NOUT,*) WRITE (NOUT,*) 'Backward errors (machine-dependent)' WRITE (NOUT,99999) (BERR(J),J=1,NRHS) WRITE (NOUT,*) + 'Estimated forward error bounds (machine-dependent)' WRITE (NOUT,99999) (FERR(J),J=1,NRHS) ELSE WRITE (NOUT,*) 'A is not positive-definite' END IF END IF * 99999 FORMAT ((3X,1P,7E11.1)) END