add numerical recipes library
This commit is contained in:
22
lib/nr/k_and_r/recipes/splint.c
Normal file
22
lib/nr/k_and_r/recipes/splint.c
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
void splint(xa,ya,y2a,n,x,y)
|
||||
float *y,x,xa[],y2a[],ya[];
|
||||
int n;
|
||||
{
|
||||
void nrerror();
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user