PROGRAM f07cgfe ! F07CGF Example Program Text ! Mark 23 Release. NAG Copyright 2011. ! .. Use Statements .. USE nag_library, ONLY : dgtcon, dgttrf, dlangt => f06rnf, nag_wp, x02ajf ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. INTEGER, PARAMETER :: nin = 5, nout = 6 ! .. Local Scalars .. REAL (KIND=nag_wp) :: anorm, rcond INTEGER :: info, n ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: d(:), dl(:), du(:), du2(:), work(:) INTEGER, ALLOCATABLE :: ipiv(:), iwork(:) ! .. Executable Statements .. WRITE (nout,*) 'F07CGF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) READ (nin,*) n ALLOCATE (d(n),dl(n-1),du(n-1),du2(n-2),work(2*n),ipiv(n),iwork(n)) ! Read the tridiagonal matrix A from data file READ (nin,*) du(1:n-1) READ (nin,*) d(1:n) READ (nin,*) dl(1:n-1) ! Compute the 1-norm of A ! f06rnf is the NAG name equivalent of the LAPACK auxiliary dlangt anorm = dlangt('1-norm',n,dl,d,du) ! Factorize the tridiagonal matrix A ! The NAG name equivalent of dgttrf is f07cdf CALL dgttrf(n,dl,d,du,du2,ipiv,info) IF (info==0) THEN ! Estimate the condition number of A ! The NAG name equivalent of dgtcon is f07cgf CALL dgtcon('1-norm',n,dl,d,du,du2,ipiv,anorm,rcond,work,iwork,info) ! Print the estimated condition number IF (rcond>=x02ajf()) THEN WRITE (nout,99999) 'Estimate of condition number = ', & 1.0_nag_wp/rcond ELSE WRITE (nout,99999) 'A is singular to working precision. RCOND = ' & , rcond END IF ELSE WRITE (nout,99998) 'The (', info, ',', info, ')', & ' element of the factor U is zero' END IF 99999 FORMAT (1X,A,1P,E10.2) 99998 FORMAT (1X,A,I3,A,I3,A,A) END PROGRAM f07cgfe