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
25
c_tools/hod/amotry.c
Normal file
25
c_tools/hod/amotry.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#define NRANSI
|
||||
#include "nrutil.h"
|
||||
|
||||
double amotry(double **p, double y[], double psum[], int ndim,
|
||||
double (*funk)(double []), int ihi, double fac)
|
||||
{
|
||||
int j;
|
||||
double fac1,fac2,ytry,*ptry;
|
||||
|
||||
ptry=dvector(1,ndim);
|
||||
fac1=(1.0-fac)/ndim;
|
||||
fac2=fac1-fac;
|
||||
for (j=1;j<=ndim;j++) ptry[j]=psum[j]*fac1-p[ihi][j]*fac2;
|
||||
ytry=(*funk)(ptry);
|
||||
if (ytry < y[ihi]) {
|
||||
y[ihi]=ytry;
|
||||
for (j=1;j<=ndim;j++) {
|
||||
psum[j] += ptry[j]-p[ihi][j];
|
||||
p[ihi][j]=ptry[j];
|
||||
}
|
||||
}
|
||||
free_dvector(ptry,1,ndim);
|
||||
return ytry;
|
||||
}
|
||||
#undef NRANSI
|
Loading…
Add table
Add a link
Reference in a new issue