#include #include "nr.h" using namespace std; void NR::powell(Vec_IO_DP &p, Mat_IO_DP &xi, const DP ftol, int &iter, DP &fret, DP func(Vec_I_DP &)) { const int ITMAX=200; const DP TINY=1.0e-25; int i,j,ibig; DP del,fp,fptt,t; int n=p.size(); Vec_DP pt(n),ptt(n),xit(n); fret=func(p); for (j=0;j del) { del=fptt-fret; ibig=i+1; } } if (2.0*(fp-fret) <= ftol*(fabs(fp)+fabs(fret))+TINY) { return; } if (iter == ITMAX) nrerror("powell exceeding maximum iterations."); for (j=0;j