* F07HAF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, KDMAX PARAMETER (NMAX=8,KDMAX=4) INTEGER LDAB PARAMETER (LDAB=KDMAX+1) CHARACTER UPLO PARAMETER (UPLO='U') * .. Local Scalars .. INTEGER I, IFAIL, INFO, J, KD, N * .. Local Arrays .. DOUBLE PRECISION AB(LDAB,NMAX), B(NMAX) * .. External Subroutines .. EXTERNAL DPBSV, X04CEF * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. Executable Statements .. WRITE (NOUT,*) 'F07HAF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N, KD IF (N.LE.NMAX .AND. KD.LE.KDMAX) THEN * * Read the upper or lower triangular part of the band matrix A * from data file * IF (UPLO.EQ.'U') THEN READ (NIN,*) ((AB(KD+1+I-J,J),J=I,MIN(N,I+KD)),I=1,N) ELSE IF (UPLO.EQ.'L') THEN READ (NIN,*) ((AB(1+I-J,J),J=MAX(1,I-KD),I),I=1,N) END IF * * Read b from data file * READ (NIN,*) (B(I),I=1,N) * * Solve the equations Ax = b for x * CALL DPBSV(UPLO,N,KD,1,AB,LDAB,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,*) IFAIL = 0 IF (UPLO.EQ.'U') THEN CALL X04CEF(N,N,0,KD,AB,LDAB,'Cholesky factor U',IFAIL) ELSE IF (UPLO.EQ.'L') THEN CALL X04CEF(N,N,KD,0,AB,LDAB,'Cholesky factor L',IFAIL) END IF * ELSE WRITE (NOUT,99998) 'The leading minor of order ', INFO, + ' is not positive definite' END IF ELSE WRITE (NOUT,*) 'NMAX and/or KDMAX too small' END IF * 99999 FORMAT ((3X,7F11.4)) 99998 FORMAT (1X,A,I3,A) END