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

NAG FL Interface Introduction
Example description
    Program f07bgfe

!     F07BGF Example Program Text

!     Mark 28.3 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use nag_library, Only: dgbcon, dgbtrf, dlangb => f06rbf, nag_wp, x02ajf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
      Character (1), Parameter         :: norm = '1'
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: anorm, rcond
      Integer                          :: i, info, j, k, kl, ku, ldab, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: ab(:,:), work(:)
      Integer, Allocatable             :: ipiv(:), iwork(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: max, min
!     .. Executable Statements ..
      Write (nout,*) 'F07BGF Example Program Results'
!     Skip heading in data file
      Read (nin,*)
      Read (nin,*) n, kl, ku
      ldab = 2*kl + ku + 1
      Allocate (ab(ldab,n),work(3*n),ipiv(n),iwork(n))

!     Read A from data file

      k = kl + ku + 1
      Read (nin,*)((ab(k+i-j,j),j=max(i-kl,1),min(i+ku,n)),i=1,n)

!     Compute norm of A
!     f06rbf is the NAG name equivalent of the LAPACK auxiliary dlangb
      anorm = dlangb(norm,n,kl,ku,ab(kl+1,1),ldab,work)

!     Factorize A

!     The NAG name equivalent of dgbtrf id f07bdf
      Call dgbtrf(n,n,kl,ku,ab,ldab,ipiv,info)

      Write (nout,*)
      If (info==0) Then

!       Estimate condition number

!       The NAG name equivalent of dgbcon is f07bgf
        Call dgbcon(norm,n,kl,ku,ab,ldab,ipiv,anorm,rcond,work,iwork,info)

        If (rcond>=x02ajf()) Then
          Write (nout,99999) 'Estimate of condition number =',                 &
            1.0_nag_wp/rcond
        Else
          Write (nout,*) 'A is singular to working precision'
        End If
      Else
        Write (nout,*) 'The factor U is singular'
      End If

99999 Format (1X,A,1P,E10.2)
    End Program f07bgfe