#include "opt.h" #include #include #include #include #include //#include using namespace std; using namespace opt_utilities; const static int max_fit_space_num=100; struct fit_space; static map fit_space_map; struct fit_space { dopt::fitter fit; /// dopt::model model; fit_space() { fit.set_method(dopt::powell_method()); dopt::chisq cq; dopt::leastsq lsq; // cq.verbose(true); fit.set_statistic(cq); } }; extern "C" { void alloc_fit_(int& n) { n=0; for(int i=1;i::iterator iter=fit_space_map.find(n); if(iter==fit_space_map.end()) { return; } fit_space_map.erase(iter); } void load_data_(const int& nfit,const int& ndatas,double* x,double* y,double* yl,double* yu,double* xl,double* xu) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { return; } // cout< ds; for(int i=0;i d(x[i],y[i],yl[i],(yu==0?yl[i]:yu[i]),(xl==0?0:xl[i]),(xu==0?0:xu[i])); // cout<second.fit.load_data(ds); } void set_model_(const int& nfit,const char* model_name) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { cerr<<"fit not found"<second.fit.set_model(opt_utilities::get_1dmodel_by_name(model_name)); } catch(opt_exception& e) { //cout<::iterator iter=fit_space_map.find(nfit); cerr<<"pname="<second.fit.set_param_value(pname,value); } void freeze_param_(const int& nfit,const char* pname) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { return; } opt_utilities::freeze_param > fp(pname); try { dynamic_cast >& >(iter->second.fit.get_param_modifier())+=fp; } catch(opt_exception& e) { iter->second.fit.set_param_modifier(fp); } } void thaw_param_(const int& nfit,const char* pname) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { return; } opt_utilities::freeze_param > fp(pname); try { dynamic_cast >& >(iter->second.fit.get_param_modifier())-=fp; } catch(opt_exception& e) { //iter->second.fit.set_param_modifier(fp); } } void perform_fit_(const int& nfit) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { return; } iter->second.fit.fit(); } void get_param_(const int& nfit,double& r,const char* pname) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { //return 0; cerr<<"fit not found"<second.fit.get_param_value(pname); } }