29 integer,
intent(in) :: n
30 real(8),
intent(in) :: x(n),f(n)
31 real(8),
intent(out) :: cf(3,n)
34 real(8) x0,x1,x2,x3,y0,y1,y2,y3
35 real(8) t0,t1,t2,t3,t4,t5,t6,t7
38 write(*,
'("Error(spline): n < 1 : ",I8)') n
47 cf(1,1)=(f(2)-f(1))/(x(2)-x(1))
55 x1=x(2)-x0; x2=x(3)-x0
57 y1=f(2)-y0; y2=f(3)-y0
58 t0=1.d0/(x1*x2*(x2-x1))
75 x1=x(2)-x0; x2=x(3)-x0; x3=x(4)-x0
76 t4=x1-x2; t5=x1-x3; t6=x2-x3
78 y1=f(2)-y0; y2=f(3)-y0; y3=f(4)-y0
79 t1=x1*x2*y3; t2=x2*x3*y1; t3=x1*x3
80 t0=1.d0/(x2*t3*t4*t5*t6)
82 t7=t0*(t1*t4+t2*t6-t3*t5)
83 t4=x1**2; t5=x2**2; t6=x3**2
84 y1=t3*t6-t1*t5; y3=t2*t5-t3*t4; y2=t1*t4-t2*t6
85 t1=t0*(x1*y1+x2*y2+x3*y3)
87 cf(1,1)=t1; cf(2,1)=t2; cf(3,1)=t7
88 cf(1,2)=t1+2.d0*t2*x1+3.d0*t7*t4
92 cf(1,3)=t1+2.d0*t2*x2+3.d0*t7*t5
95 cf(1,4)=t1+2.d0*t2*x3+3.d0*t7*t6
102 x1=x(i-1)-x0; x2=x(i+1)-x0; x3=x(i+2)-x0
103 t4=x1-x2; t5=x1-x3; t6=x2-x3
105 y1=f(i-1)-y0; y2=f(i+1)-y0; y3=f(i+2)-y0
106 t1=x1*x2*y3; t2=x2*x3*y1; t3=x1*x3
107 t0=1.d0/(x2*t3*t4*t5*t6)
109 t7=t0*(t1*t4+t2*t6-t3*t5)
110 t4=x1**2; t5=x2**2; t6=x3**2
111 y1=t3*t6-t1*t5; y2=t1*t4-t2*t6; y3=t2*t5-t3*t4
112 t1=t0*(x1*y1+x2*y2+x3*y3)
114 cf(1,i)=t1; cf(2,i)=t2; cf(3,i)=t7
116 c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