beginning to fold in HOD code with jeremy tinker's approval

This commit is contained in:
P.M. Sutter 2013-12-30 22:48:07 -06:00
parent d8108d3a8e
commit 44cd0eb71f
95 changed files with 21950 additions and 0 deletions

25
c_tools/hod/amotry.c Normal file
View 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