mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +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
29
c_tools/hod/midinf.c
Normal file
29
c_tools/hod/midinf.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#define FUNC(x) ((*funk)(1.0/(x))/((x)*(x)))
|
||||
|
||||
double midinf(double (*funk)(double), double aa, double bb, int n)
|
||||
{
|
||||
double x,tnm,sum,del,ddel,b,a;
|
||||
static double s;
|
||||
int it,j;
|
||||
|
||||
b=1.0/aa;
|
||||
a=1.0/bb;
|
||||
if (n == 1) {
|
||||
return (s=(b-a)*FUNC(0.5*(a+b)));
|
||||
} else {
|
||||
for(it=1,j=1;j<n-1;j++) it *= 3;
|
||||
tnm=it;
|
||||
del=(b-a)/(3.0*tnm);
|
||||
ddel=del+del;
|
||||
x=a+0.5*del;
|
||||
sum=0.0;
|
||||
for (j=1;j<=it;j++) {
|
||||
sum += FUNC(x);
|
||||
x += ddel;
|
||||
sum += FUNC(x);
|
||||
x += del;
|
||||
}
|
||||
return (s=(s+(b-a)*sum/tnm)/3.0);
|
||||
}
|
||||
}
|
||||
#undef FUNC
|
Loading…
Add table
Add a link
Reference in a new issue