* F07JSF 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 PARAMETER (LDB=NMAX) CHARACTER UPLO PARAMETER (UPLO='U') * .. Local Scalars .. INTEGER I, IFAIL, INFO, J, N, NRHS * .. Local Arrays .. COMPLEX *16 B(LDB,NRHSMX), E(NMAX-1) DOUBLE PRECISION D(NMAX) CHARACTER CLABS(1), RLABS(1) * .. External Subroutines .. EXTERNAL X04DBF, ZPTTRF, ZPTTRS * .. Executable Statements .. WRITE (NOUT,*) 'F07JSF 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 bidiagonal part of the tridiagonal matrix A from * data file * READ (NIN,*) (E(I),I=1,N-1) READ (NIN,*) (D(I),I=1,N) * * Read the right hand matrix B * READ (NIN,*) ((B(I,J),J=1,NRHS),I=1,N) * * Factorize the tridiagonal matrix A * CALL ZPTTRF(N,D,E,INFO) * IF (INFO.EQ.0) THEN * * Solve the equations AX = B * CALL ZPTTRS(UPLO,N,NRHS,D,E,B,LDB,INFO) * * Print the solution * IFAIL = 0 CALL X04DBF('General',' ',N,NRHS,B,LDB,'Bracketed',' ', + 'Solution(s)','Integer',RLABS,'Integer',CLABS, + 80,0,IFAIL) * ELSE WRITE (NOUT,99999) 'The leading minor of order ', INFO, + ' is not positive definite' END IF ELSE WRITE (NOUT,*) 'NMAX and/or NRHSMX too small' END IF STOP * 99999 FORMAT (1X,A,I3,A) END