NAG Library Manual, Mark 30.3
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program f07jgfe

!     F07JGF Example Program Text

!     Mark 30.3 Release. nAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: dptcon, dpttrf, f06rpf, 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(:), e(:), work(:)
!     .. Executable Statements ..
      Write (nout,*) 'F07JGF Example Program Results'
      Write (nout,*)
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n

      Allocate (d(n),e(n-1),work(n))

!     Read the lower bidiagonal part of the tridiagonal matrix A from
!     data file

      Read (nin,*) d(1:n)
      Read (nin,*) e(1:n-1)

!     Compute the 1-norm of A
      anorm = f06rpf('1-norm',n,d,e)

!     Factorize the tridiagonal matrix A
!     The NAG name equivalent of dpttrf is f07jdf
      Call dpttrf(n,d,e,info)

      If (info==0) Then

!       Estimate the condition number of A
!       The NAG name equivalent of dptcon is f07jgf
        Call dptcon(n,d,e,anorm,rcond,work,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 leading minor of order ', info,                &
          ' is not positive definite'
      End If

99999 Format (1X,A,1P,E10.2)
99998 Format (1X,A,I3,A)
    End Program f07jgfe