* F07PPF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX PARAMETER (NMAX=8) INTEGER LDB, LDX, NRHSMX PARAMETER (LDB=NMAX,LDX=NMAX,NRHSMX=NMAX) CHARACTER UPLO PARAMETER (UPLO='U') * .. Local Scalars .. DOUBLE PRECISION RCOND INTEGER I, IFAIL, INFO, J, N, NRHS * .. Local Arrays .. COMPLEX *16 AFP((NMAX*(NMAX+1))/2), AP((NMAX*(NMAX+1))/2), + B(LDB,NRHSMX), 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 X04DBF, ZHPSVX * .. Executable Statements .. WRITE (NOUT,*) 'F07PPF 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 upper or lower triangular part of the matrix A from * data file * IF (UPLO.EQ.'U') THEN READ (NIN,*) ((AP(I+(J*(J-1))/2),J=I,N),I=1,N) ELSE IF (UPLO.EQ.'L') THEN READ (NIN,*) ((AP(I+((2*N-J)*(J-1))/2),J=1,I),I=1,N) END IF * * Read B from data file * READ (NIN,*) ((B(I,J),J=1,NRHS),I=1,N) * * Solve the equations AX = B for X * CALL ZHPSVX('Not factored',UPLO,N,NRHS,AP,AFP,IPIV,B,LDB,X,LDX, + RCOND,FERR,BERR,WORK,RWORK,INFO) * IF ((INFO.EQ.0) .OR. (INFO.EQ.N+1)) THEN * * Print solution, error bounds and condition number * 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) WRITE (NOUT,*) WRITE (NOUT,*) 'Estimate of reciprocal condition number' WRITE (NOUT,99999) RCOND WRITE (NOUT,*) * IF (INFO.EQ.N+1) THEN WRITE (NOUT,*) WRITE (NOUT,*) + 'The matrix A is singular to working precision' END IF ELSE WRITE (NOUT,99998) 'The diagonal block ', INFO, + ' of D 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) END