-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathratint.f
41 lines (41 loc) · 849 Bytes
/
ratint.f
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
SUBROUTINE RATINT(XA,YA,N,X,Y,DY)
PARAMETER (NMAX=10,TINY=1.E-25)
DIMENSION XA(N),YA(N),C(NMAX),D(NMAX)
NS=1
HH=ABS(X-XA(1))
DO 11 I=1,N
H=ABS(X-XA(I))
IF (H.EQ.0.)THEN
Y=YA(I)
DY=0.0
RETURN
ELSE IF (H.LT.HH) THEN
NS=I
HH=H
ENDIF
C(I)=YA(I)
D(I)=YA(I)+TINY
11 CONTINUE
Y=YA(NS)
NS=NS-1
DO 13 M=1,N-1
DO 12 I=1,N-M
W=C(I+1)-D(I)
H=XA(I+M)-X
T=(XA(I)-X)*D(I)/H
DD=T-C(I+1)
IF(DD.EQ.0.)PAUSE
DD=W/DD
D(I)=C(I+1)*DD
C(I)=T*DD
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