Program g10acfe
! G10ACF Example Program Text
! Mark 26.1 Release. NAG Copyright 2016.
! .. Use Statements ..
Use nag_library, Only: g10acf, g10zaf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: crit, df, rho, rss, tol, u
Integer :: i, ifail, ldc, lwk, lwt, maxcal, n, &
nord
Character (1) :: method, weight
! .. Local Arrays ..
Real (Kind=nag_wp), Allocatable :: c(:,:), h(:), res(:), wk(:), wt(:), &
wwt(:), x(:), xord(:), y(:), &
yhat(:), yord(:)
Integer, Allocatable :: iwrk(:)
! .. Executable Statements ..
Write (nout,*) 'G10ACF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
Read (nin,*) method, weight, n
If (weight=='W' .Or. weight=='w') Then
lwt = n
Else
lwt = 0
End If
ldc = n - 1
lwk = 7*(n+2)
Allocate (x(n),y(n),wt(lwt),xord(n),yord(n),wwt(n),yhat(n),c(ldc,3), &
res(n),h(n),wk(lwk),iwrk(n))
! Read in data
If (lwt>0) Then
Read (nin,*)(x(i),y(i),wt(i),i=1,n)
Else
Read (nin,*)(x(i),y(i),i=1,n)
End If
! Read in control parameters
Read (nin,*) u, tol, maxcal, crit
! Sort data, removing ties and weighting accordingly
ifail = 0
Call g10zaf(weight,n,x,y,wt,nord,xord,yord,wwt,rss,iwrk,ifail)
! Fit cubic spline
ifail = 0
Call g10acf(method,'W',nord,xord,yord,wwt,yhat,c,ldc,rss,df,res,h,crit, &
rho,u,tol,maxcal,wk,ifail)
! Display results
Write (nout,99999) 'Residual sum of squares = ', rss
Write (nout,99999) 'Degrees of freedom = ', df
Write (nout,99999) 'RHO = ', rho
Write (nout,*)
Write (nout,*) ' Input data Output results'
Write (nout,*) ' I X Y YHAT H'
Write (nout,99998)(i,xord(i),yord(i),yhat(i),h(i),i=1,nord)
99999 Format (1X,A,F10.2)
99998 Format (I4,2F8.3,6X,2F8.3)
End Program g10acfe