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

NAG AD Library Introduction
Example description
    Program f11xe_p0w_fe

!     F11XE_P0W_F Example Program Text

!     Mark 29.3 Release. NAG Copyright 2023.

!     .. Use Statements ..
      Use iso_c_binding, Only: c_ptr
      Use nagad_library, Only: f11xe_p0w_f
      Use nag_library, Only: nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Type (c_ptr)                     :: ad_handle
      Integer                          :: i, ifail, n, nnz
      Character (1)                    :: check
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: a(:), x(:), y(:)
      Integer, Allocatable             :: icol(:), irow(:)
!     .. Executable Statements ..
      Write (nout,*) 'F11XE_P0W_F Example Program Results'
!     Skip heading in data file
      Read (nin,*)

!     Read order of matrix and number of nonzero entries
      Read (nin,*) n
      Read (nin,*) nnz

      Allocate (a(nnz),x(n),y(n),icol(nnz),irow(nnz))

!     Read the matrix A
      Do i = 1, nnz
        Read (nin,*) a(i), irow(i), icol(i)
      End Do

!     Read the vector x
      Read (nin,*) x(1:n)

!     Calculate matrix-vector product
      check = 'C'
      ifail = 0
      Call f11xe_p0w_f(ad_handle,n,nnz,a,irow,icol,check,x,y,ifail)

!     Output results
      Write (nout,*) ' Matrix-vector product'
      Write (nout,99999)(y(i),i=1,n)

99999 Format (1X,1P,E16.4)
    End Program f11xe_p0w_fe