-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpolint.for
43 lines (43 loc) · 1004 Bytes
/
polint.for
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
SUBROUTINE polint(xa,ya,n,x,y,dy)
use precision,only:p_
implicit none
INTEGER n,NMAX
REAL(P_) dy,x,y,xa(n),ya(n)
PARAMETER (NMAX=10)
INTEGER i,m,ns
REAL(P_) den,dif,dift,ho,hp,w,c(NMAX),d(NMAX)
ns=1
dif=abs(x-xa(1))
do 11 i=1,n
dift=abs(x-xa(i))
if (dift.lt.dif) then
ns=i
dif=dift
endif
c(i)=ya(i)
d(i)=ya(i)
11 continue
y=ya(ns)
ns=ns-1
do 13 m=1,n-1
do 12 i=1,n-m
ho=xa(i)-x
hp=xa(i+m)-x
w=c(i+1)-d(i)
den=ho-hp
if(den.eq.0.) stop 'failure in polint'
den=w/den
d(i)=hp*den
c(i)=ho*den
12 continue
if (2*ns.lt.n-m)then
dy=c(ns+1)
else
dy=d(ns)
ns=ns-1
endif
y=y+dy
13 continue
return
END
C (C) Copr. 1986-92 Numerical Recipes Software ,4-#.