?? amotsa.c
字號:
#include <math.h>#define NRANSI#include "nrutil.h"extern long idum;extern float tt;float amotsa(float **p, float y[], float psum[], int ndim, float pb[], float *yb, float (*funk)(float []), int ihi, float *yhi, float fac){ float ran1(long *idum); int j; float fac1,fac2,yflu,ytry,*ptry; ptry=vector(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 <= *yb) { for (j=1;j<=ndim;j++) pb[j]=ptry[j]; *yb=ytry; } yflu=ytry-tt*log(ran1(&idum)); if (yflu < *yhi) { y[ihi]=ytry; *yhi=yflu; for (j=1;j<=ndim;j++) { psum[j] += ptry[j]-p[ihi][j]; p[ihi][j]=ptry[j]; } } free_vector(ptry,1,ndim); return yflu;}#undef NRANSI
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -