PROGRAM f07hffe ! F07HFF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : dpbequ, dscal, f06fcf, nag_wp, x02ajf, x02amf, & x02bhf, x04cef ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. REAL (KIND=nag_wp), PARAMETER :: one = 1.0_nag_wp REAL (KIND=nag_wp), PARAMETER :: thresh = 0.1_nag_wp INTEGER, PARAMETER :: nin = 5, nout = 6 CHARACTER (1), PARAMETER :: uplo = 'U' ! .. Local Scalars .. REAL (KIND=nag_wp) :: amax, big, scond, small INTEGER :: i, i0, i1, ifail, ilen, info, j, kd, & ldab, n ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: ab(:,:), s(:) ! .. Intrinsic Functions .. INTRINSIC max, min, real ! .. Executable Statements .. WRITE (nout,*) 'F07HFF Example Program Results' WRITE (nout,*) FLUSH (nout) ! Skip heading in data file READ (nin,*) READ (nin,*) n, kd ldab = kd + 1 ALLOCATE (ab(ldab,n),s(n)) ! 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 ! Print the matrix A ! ifail: behaviour on error exit ! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft ifail = 0 IF (uplo=='U') THEN CALL x04cef(n,n,0,kd,ab,ldab,'Matrix A',ifail) ELSE IF (uplo=='L') THEN CALL x04cef(n,n,kd,0,ab,ldab,'Matrix A',ifail) END IF WRITE (nout,*) ! Compute diagonal scaling factors ! The NAG name equivalent of dpbequ is f07hff CALL dpbequ(uplo,n,kd,ab,ldab,s,scond,amax,info) IF (info>0) THEN WRITE (nout,99999) 'Diagonal element', info, ' of A is non positive' ELSE ! Print SCOND, AMAX and the scale factors WRITE (nout,99998) 'SCOND =', scond, ', AMAX =', amax WRITE (nout,*) WRITE (nout,*) 'Diagonal scaling factors' WRITE (nout,99997) s(1:n) WRITE (nout,*) FLUSH (nout) ! Compute values close to underflow and overflow small = x02amf()/(x02ajf()*real(x02bhf(),kind=nag_wp)) big = one/small IF ((scondbig)) THEN ! Scale A IF (uplo=='U') THEN ! The NAG name equivalent of dscal is f06edf DO j = 1, n i0 = max(1,j-kd) i1 = 1 + i0 - (j-kd) ilen = j - i0 + 1 CALL dscal(ilen,s(j),ab(i1,j),1) CALL f06fcf(ilen,s(i0),1,ab(i1,j),1) END DO ELSE IF (uplo=='L') THEN DO j = 1, n i1 = 1 ilen = min(n,j+kd) - j + 1 CALL dscal(ilen,s(j),ab(i1,j),1) CALL f06fcf(ilen,s(j),1,ab(i1,j),1) END DO END IF ! Print the scaled matrix ifail = 0 IF (uplo=='U') THEN CALL x04cef(n,n,0,kd,ab,ldab,'Scaled matrix',ifail) ELSE IF (uplo=='L') THEN CALL x04cef(n,n,kd,0,ab,ldab,'Scaled matrix',ifail) END IF END IF END IF 99999 FORMAT (1X,A,I4,A) 99998 FORMAT (1X,2(A,1P,E8.1)) 99997 FORMAT ((1X,1P,7E11.1)) END PROGRAM f07hffe