* F07HNF 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 .. COMPLEX *16 AB(LDAB,NMAX), B(NMAX) CHARACTER CLABS(1), RLABS(1) * .. External Subroutines .. EXTERNAL X04DFF, ZPBSV * .. Intrinsic Functions .. INTRINSIC MAX, MIN * .. Executable Statements .. WRITE (NOUT,*) 'F07HNF 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 ZPBSV(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 X04DFF(N,N,0,KD,AB,LDAB,'Bracketed','F7.4', + 'Cholesky factor U','Integer',RLABS, + 'Integer',CLABS,80,0,IFAIL) ELSE IF (UPLO.EQ.'L') THEN CALL X04DFF(N,N,KD,0,AB,LDAB,'Bracketed','F7.4', + 'Cholesky factor L','Integer',RLABS, + 'Integer',CLABS,80,0,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 STOP * 99999 FORMAT ((3X,4(' (',F7.4,',',F7.4,')',:))) 99998 FORMAT (1X,A,I3,A) END