* F07CVF 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 .. COMPLEX *16 B(LDB,NRHSMX), D(NMAX), DF(NMAX), DL(NMAX-1), + DLF(NMAX-1), DU(NMAX-1), DU2(NMAX-2), + DUF(NMAX-1), WORK(2*NMAX), X(LDX,NRHSMX) DOUBLE PRECISION BERR(NRHSMX), FERR(NRHSMX), RWORK(NMAX) INTEGER IPIV(NMAX) CHARACTER CLABS(1), RLABS(1) * .. External Subroutines .. EXTERNAL F06TFF, X04DBF, ZCOPY, ZGTRFS, ZGTTRF, ZGTTRS * .. Executable Statements .. WRITE (NOUT,*) 'F07CVF 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 tridiagonal matrix A from data file * READ (NIN,*) (DU(I),I=1,N-1) READ (NIN,*) (D(I),I=1,N) READ (NIN,*) (DL(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 DUF, DF and DLF, and copy B into X * CALL ZCOPY(N-1,DU,1,DUF,1) CALL ZCOPY(N,D,1,DF,1) CALL ZCOPY(N-1,DL,1,DLF,1) CALL F06TFF('General',N,NRHS,B,LDB,X,LDX) * * Factorize the copy of the tridiagonal matrix A * CALL ZGTTRF(N,DLF,DF,DUF,DU2,IPIV,INFO) * IF (INFO.EQ.0) THEN * * Solve the equations AX = B * CALL ZGTTRS('No transpose',N,NRHS,DLF,DF,DUF,DU2,IPIV,X,LDX, + INFO) * * Improve the solution and compute error estimates * CALL ZGTRFS('No transpose',N,NRHS,DL,D,DU,DLF,DF,DUF,DU2, + IPIV,B,LDB,X,LDX,FERR,BERR,WORK,RWORK,INFO) * * Print the solution and the forward and backward error * estimates * 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,*) WRITE (NOUT,*) + 'Estimated forward error bounds (machine-dependent)' WRITE (NOUT,99999) (FERR(J),J=1,NRHS) ELSE WRITE (NOUT,99998) 'The (', INFO, ',', INFO, ')', + ' element of the factor U is zero' 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,I3,A,A) END