* F07JHF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, NRHSMX PARAMETER (NMAX=50,NRHSMX=4) INTEGER LDB, LDX PARAMETER (LDB=NMAX,LDX=NMAX) * .. Local Scalars .. INTEGER I, IFAIL, INFO, J, N, NRHS * .. Local Arrays .. DOUBLE PRECISION B(LDB,NRHSMX), BERR(NRHSMX), D(NMAX), DF(NMAX), + E(NMAX-1), EF(NMAX-1), FERR(NRHSMX), + WORK(2*NMAX), X(LDX,NRHSMX) * .. External Subroutines .. EXTERNAL DCOPY, DPTRFS, DPTTRF, DPTTRS, F06QFF, X04CAF * .. Executable Statements .. WRITE (NOUT,*) 'F07JHF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N, NRHS IF (N.LE.NMAX .AND. NRHS.LE.NRHSMX) THEN * * Read the lower bidiagonal part of the tridiagonal matrix A from * data file * READ (NIN,*) (D(I),I=1,N) READ (NIN,*) (E(I),I=1,N-1) * * Read the right hand matrix B * READ (NIN,*) ((B(I,J),J=1,NRHS),I=1,N) * * Copy A into DF and EF, and copy B into X * CALL DCOPY(N,D,1,DF,1) CALL DCOPY(N-1,E,1,EF,1) CALL F06QFF('General',N,NRHS,B,LDB,X,LDX) * * Factorize the copy of the tridiagonal matrix A * CALL DPTTRF(N,DF,EF,INFO) * IF (INFO.EQ.0) THEN * * Solve the equations AX = B * CALL DPTTRS(N,NRHS,DF,EF,X,LDX,INFO) * * Improve the solution and compute error estimates * CALL DPTRFS(N,NRHS,D,E,DF,EF,B,LDB,X,LDX,FERR,BERR,WORK, + INFO) * * Print the solution and the forward and backward error * estimates * 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,*) WRITE (NOUT,*) + 'Estimated forward error bounds (machine-dependent)' WRITE (NOUT,99999) (FERR(J),J=1,NRHS) ELSE WRITE (NOUT,99998) 'The leading minor of order ', INFO, + ' is not positive definite' END IF ELSE WRITE (NOUT,*) 'NMAX and/or NRHSMX too small' END IF * 99999 FORMAT ((3X,1P,7E11.1)) 99998 FORMAT (1X,A,I3,A) END