Program e01zafe
! Mark 30.3 Release. nAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: e01zaf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: ans, tv, wf
Integer :: d, i, ifail, lx
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: axis(:), point(:), v(:)
Integer, Allocatable :: narr(:)
! .. Intrinsic Procedures ..
Intrinsic :: abs, product
! .. Executable Statements ..
Write (nout,*) 'E01ZAF Example Program Results'
! Skip Heading
Read (nin,*)
! Read in dimension
Read (nin,*) d
! Allocate arrays
Allocate (narr(d),point(d),axis(2*d))
! Read in narr and point
Read (nin,*) narr(1:d)
Read (nin,*) point(1:d)
! Allocate data
Allocate (v(product(narr)))
! Read in in axis and data
Do i = 1, d
Read (nin,*) axis(i*2-1:i*2)
End Do
Do i = 1, product(narr(2:))
Read (nin,*) v(narr(1)*i-3:narr(1)*i)
End Do
Read (nin,*) wf
! Set remaining Variables
lx = 2*d
ifail = 0
! Set true value of function
tv = point(1)**3 - point(2)**2 + point(3)
Write (nout,99999) 'True Value :', tv
! Do weighted average method
Call e01zaf(d,narr,.True.,axis,lx,v,point,1,1,wf,ans,ifail)
Write (nout,99998) 'Weighted Average:', ans, 'Error :', abs(ans-tv)
! Do Linear Method
Call e01zaf(d,narr,.True.,axis,lx,v,point,2,1,wf,ans,ifail)
Write (nout,99998) 'Linear:', ans, 'Error :', abs(ans-tv)
! Do Cubic Convolution Method
Call e01zaf(d,narr,.True.,axis,lx,v,point,3,2,wf,ans,ifail)
Write (nout,99998) 'Cubic:', ans, 'Error :', abs(ans-tv)
99999 Format (A12,F9.5)
99998 Format (A20,F9.5,2X,A,F9.5)
End Program e01zafe