21 lines
434 B
C
21 lines
434 B
C
|
|
void splint(float xa[], float ya[], float y2a[], int n, float x, float *y)
|
|
{
|
|
void nrerror(char error_text[]);
|
|
int klo,khi,k;
|
|
float h,b,a;
|
|
|
|
klo=1;
|
|
khi=n;
|
|
while (khi-klo > 1) {
|
|
k=(khi+klo) >> 1;
|
|
if (xa[k] > x) khi=k;
|
|
else klo=k;
|
|
}
|
|
h=xa[khi]-xa[klo];
|
|
if (h == 0.0) nrerror("Bad xa input to routine splint");
|
|
a=(xa[khi]-x)/h;
|
|
b=(x-xa[klo])/h;
|
|
*y=a*ya[klo]+b*ya[khi]+((a*a*a-a)*y2a[klo]+(b*b*b-b)*y2a[khi])*(h*h)/6.0;
|
|
}
|