PROGRAM f04cffe ! F04CFF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : f04cff, nag_wp, x04dbf ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 CHARACTER (1), PARAMETER :: uplo = 'U' ! .. Local Scalars .. REAL (KIND=nag_wp) :: errbnd, rcond INTEGER :: i, ierr, ifail, j, kd, ldab, ldb, n, & nrhs ! .. Local Arrays .. COMPLEX (KIND=nag_wp), ALLOCATABLE :: ab(:,:), b(:,:) CHARACTER (1) :: clabs(1), rlabs(1) ! .. Intrinsic Functions .. INTRINSIC max, min ! .. Executable Statements .. WRITE (nout,*) 'F04CFF Example Program Results' WRITE (nout,*) FLUSH (nout) ! Skip heading in data file READ (nin,*) READ (nin,*) n, kd, nrhs ldab = kd + 1 ldb = n ALLOCATE (ab(ldab,n),b(ldb,nrhs)) ! Read the upper or lower triangular part of the band matrix A ! from data file IF (uplo=='U') THEN DO i = 1, n READ (nin,*) (ab(kd+1+i-j,j),j=i,min(n,i+kd)) END DO ELSE IF (uplo=='L') THEN DO i = 1, n READ (nin,*) (ab(1+i-j,j),j=max(1,i-kd),i) END DO END IF ! Read B from data file READ (nin,*) (b(i,1:nrhs),i=1,n) ! Solve the equations AX = B for X ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 1 CALL f04cff(uplo,n,kd,nrhs,ab,ldab,b,ldb,rcond,errbnd,ifail) IF (ifail==0) THEN ! Print solution, estimate of condition number and approximate ! error bound ierr = 0 CALL x04dbf('General',' ',n,nrhs,b,ldb,'Bracketed','F7.4', & 'Solution','Integer',rlabs,'Integer',clabs,80,0,ierr) WRITE (nout,*) WRITE (nout,*) 'Estimate of condition number' WRITE (nout,99999) 1.0E0_nag_wp/rcond WRITE (nout,*) WRITE (nout,*) 'Estimate of error bound for computed solutions' WRITE (nout,99999) errbnd ELSE IF (ifail==n+1) THEN ! Matrix A is numerically singular. Print estimate of ! reciprocal of condition number and solution WRITE (nout,*) WRITE (nout,*) 'Estimate of reciprocal of condition number' WRITE (nout,99999) rcond WRITE (nout,*) FLUSH (nout) ierr = 0 CALL x04dbf('General',' ',n,nrhs,b,ldb,'Bracketed','F7.4', & 'Solution','Integer',rlabs,'Integer',clabs,80,0,ierr) ELSE IF (ifail>0 .AND. ifail<=n) THEN ! The matrix A is not positive definite to working precision WRITE (nout,99998) 'The leading minor of order ', ifail, & ' is not positive definite' ELSE WRITE (nout,99997) ifail END IF 99999 FORMAT (4X,1P,E9.1) 99998 FORMAT (1X,A,I3,A) 99997 FORMAT (1X,' ** F04CFF returned with IFAIL = ',I5) END PROGRAM f04cffe