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

NAG FL Interface Introduction
Example description
    Program f07cufe

!     F07CUF Example Program Text

!     Mark 27.3 Release. NAG Copyright 2021.

!     .. Use Statements ..
      Use nag_library, Only: f06unf, nag_wp, x02ajf, zgtcon, zgttrf
!     .. 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 ..
      Complex (Kind=nag_wp), Allocatable :: d(:), dl(:), du(:), du2(:),        &
                                          work(:)
      Integer, Allocatable             :: ipiv(:)
!     .. Executable Statements ..
      Write (nout,*) 'F07CUF 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))

!     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
      anorm = f06unf('1-norm',n,dl,d,du)

!     Factorize the tridiagonal matrix A
!     The NAG name equivalent of zgttrf is f07crf
      Call zgttrf(n,dl,d,du,du2,ipiv,info)

      If (info==0) Then

!       Estimate the condition number of A
!       The NAG name equivalent of zgtcon is f07cuf
        Call zgtcon('1-norm',n,dl,d,du,du2,ipiv,anorm,rcond,work,info)

!       Print the estimated condition number

        If (rcond>=x02ajf()) Then
          Write (nout,99999) 'Estimate of condition number = ',                &
            1.0E0_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 f07cufe