mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
beginning to fold in HOD code with jeremy tinker's approval
This commit is contained in:
parent
d8108d3a8e
commit
44cd0eb71f
95 changed files with 21950 additions and 0 deletions
39
c_tools/hod/polint.c
Normal file
39
c_tools/hod/polint.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#define NRANSI
|
||||
#include "nrutil.h"
|
||||
|
||||
void polint(double xa[], double ya[], int n, double x, double *y, double *dy)
|
||||
{
|
||||
int i,m,ns=1;
|
||||
double den,dif,dift,ho,hp,w;
|
||||
double *c,*d;
|
||||
|
||||
dif=fabs(x-xa[1]);
|
||||
c=dvector(1,n);
|
||||
d=dvector(1,n);
|
||||
for (i=1;i<=n;i++) {
|
||||
if ( (dift=fabs(x-xa[i])) < dif) {
|
||||
ns=i;
|
||||
dif=dift;
|
||||
}
|
||||
c[i]=ya[i];
|
||||
d[i]=ya[i];
|
||||
}
|
||||
*y=ya[ns--];
|
||||
for (m=1;m<n;m++) {
|
||||
for (i=1;i<=n-m;i++) {
|
||||
ho=xa[i]-x;
|
||||
hp=xa[i+m]-x;
|
||||
w=c[i+1]-d[i];
|
||||
if ( (den=ho-hp) == 0.0) nrerror("Error in routine polint");
|
||||
den=w/den;
|
||||
d[i]=hp*den;
|
||||
c[i]=ho*den;
|
||||
}
|
||||
*y += (*dy=(2*ns < (n-m) ? c[ns+1] : d[ns--]));
|
||||
}
|
||||
free_dvector(d,1,n);
|
||||
free_dvector(c,1,n);
|
||||
}
|
||||
#undef NRANSI
|
Loading…
Add table
Add a link
Reference in a new issue