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

NAG AD Library Introduction
Example description
    Program f03bf_p0w_fe

!     F03BF_P0W_F Example Program Text

!     Mark 28.3 Release. NAG Copyright 2022.

!     .. Use Statements ..
      Use iso_c_binding, Only: c_ptr
      Use nagad_library, Only: f03bf_p0w_f, f07fd_p0w_f
      Use nag_library, Only: nag_wp, x04caf
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
      Character (1), Parameter         :: uplo = 'l'
!     .. Local Scalars ..
      Type (c_ptr)                     :: ad_handle
      Real (Kind=nag_wp)               :: d
      Integer                          :: i, id, ifail, lda, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:,:)
!     .. Executable Statements ..
      Write (nout,*) 'F03BF_P0W_F Example Program Results'

!     Skip heading in data file
      Read (nin,*)

      Read (nin,*) n
      lda = n
      Allocate (a(lda,n))

      Read (nin,*)(a(i,1:n),i=1,n)

!     Factorize A
!     The NAG name equivalent of dpotrf is f07fdf
      ifail = 0
      Call f07fd_p0w_f(ad_handle,uplo,n,a,lda,ifail)

      Write (nout,*)
      Flush (nout)
      ifail = 0
      Call x04caf('L','N',n,n,a,lda,'Array A after factorization',ifail)

      ifail = 0
      Call f03bf_p0w_f(ad_handle,n,a,lda,d,id,ifail)

      Write (nout,*)
      Write (nout,99999) d, id
      Write (nout,*)
      Write (nout,99998) d*2.0_nag_wp**id

99999 Format (1X,'D = ',F13.5,' ID = ',I12)
99998 Format (1X,'Value of determinant = ',E13.5)
    End Program f03bf_p0w_fe