* F07HVF Example Program Text * Mark 15 Release. NAG Copyright 1991. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) COMPLEX*16 ZERO PARAMETER (ZERO=(0.0D0,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 .. COMPLEX*16 AB(LDAB,NMAX), AFB(LDAFB,NMAX), B(LDB,NRHMAX), + WORK(2*NMAX), X(LDX,NMAX) DOUBLE PRECISION BERR(NRHMAX), FERR(NRHMAX), RWORK(NMAX) CHARACTER CLABS(1), RLABS(1) * .. External Subroutines .. EXTERNAL ZPBRFS, ZPBTRF, ZPBTRS, F06TFF, F06THF, X04DBF * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. Executable Statements .. WRITE (NOUT,*) 'F07HVF 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 F06THF('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 F06TFF('General',KD+1,N,AB,LDAB,AFB,LDAFB) CALL F06TFF('General',N,NRHS,B,LDB,X,LDX) * * Factorize A in the array AFB * CALL ZPBTRF(UPLO,N,KD,AFB,LDAFB,INFO) * WRITE (NOUT,*) IF (INFO.EQ.0) THEN * * Compute solution in the array X * CALL ZPBTRS(UPLO,N,KD,NRHS,AFB,LDAFB,X,LDX,INFO) * * Improve solution, and compute backward errors and * estimated bounds on the forward errors * CALL ZPBRFS(UPLO,N,KD,NRHS,AB,LDAB,AFB,LDAFB,B,LDB,X,LDX, + FERR,BERR,WORK,RWORK,INFO) * * Print solution * IFAIL = 0 CALL X04DBF('General',' ',N,NRHS,X,LDX,'Bracketed','F7.4', + 'Solution(s)','Integer',RLABS,'Integer',CLABS, + 80,0,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 STOP * 99999 FORMAT ((5X,1P,4(D11.1,7X))) END