COSMOS v7.655  COSMOSv7655
(AirShowerMC)
kintp3.f
Go to the documentation of this file.
1 ! ****************************************************************
2 ! * *
3 ! * kintp3: lagrange's 3-point interpolation *
4 ! * *
5 ! ************************ tested 87.03.07 ***************k.k ****
6 !
7 ! /usage/ call kintp3(f, intv, n, x1, h, x, ans)
8 !
9 ! f: table of some function values to be interpolated
10 ! intv: f is used with step intv
11 ! n: # of available f
12 ! x1: f containes the function values at x1, x1+h,...x1+(n-1)*h
13 ! h: interval of argument
14 ! x: argument at which the value of the function is to be obtained
15 !
16 ! ans: interpolated value
17 !
18  subroutine kintp3(f, intv, n, x1, h, x, ans)
19  implicit none
20 !
21  integer intv, n
22  real*8 f(intv, n), x1, h, x, ans
23 !
24  integer i
25  real*8 p, ta, tb
26 !
27  if(n .lt. 3) then
28  ans=0.
29  else
30  i=(x-x1)/h
31  if(i .lt. 0) then
32  i=0
33  elseif(i .gt. 0) then
34  if(i+3 .gt. n) then
35  i=n-3
36  endif
37  endif
38  p=(x-x1-h*float(i+1))/h
39  ta=p-1.
40  tb=p+1.
41  ans=0.5*p*(ta*f(1, i+1)+tb*f(1, i+3)) - ta*tb*f(1, i+2)
42  endif
43  end
44 
45 
subroutine kintp3(f, intv, n, x1, h, x, ans)
Definition: kintp3.f:19