* F07JNF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX PARAMETER (NMAX=8) * .. Local Scalars .. INTEGER I, INFO, N * .. Local Arrays .. COMPLEX *16 B(NMAX), E(NMAX-1) DOUBLE PRECISION D(NMAX) * .. External Subroutines .. EXTERNAL ZPTSV * .. Executable Statements .. WRITE (NOUT,*) 'F07JNF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N IF (N.LE.NMAX) THEN * * Read the lower bidiagonal part of the tridiagonal matrix A and * the right hand side b from data file * READ (NIN,*) (D(I),I=1,N) READ (NIN,*) (E(I),I=1,N-1) READ (NIN,*) (B(I),I=1,N) * * Solve the equations Ax = b for x * CALL ZPTSV(N,1,D,E,B,N,INFO) * IF (INFO.EQ.0) THEN * * Print solution * WRITE (NOUT,*) 'Solution' WRITE (NOUT,99999) (B(I),I=1,N) * * Print details of factorization * WRITE (NOUT,*) WRITE (NOUT,*) 'Diagonal elements of the diagonal matrix D' WRITE (NOUT,99998) (D(I),I=1,N) WRITE (NOUT,*) WRITE (NOUT,*) + 'Sub-diagonal elements of the Cholesky factor L' WRITE (NOUT,99999) (E(I),I=1,N-1) * ELSE WRITE (NOUT,99997) 'The leading minor of order ', INFO, + ' is not positive definite' END IF ELSE WRITE (NOUT,*) 'NMAX too small' END IF * 99999 FORMAT (4(' (',F8.4,',',F8.4,')',:)) 99998 FORMAT ((2X,F7.4,3(11X,F7.4))) 99997 FORMAT (1X,A,I3,A) END