#include "opt.h" #include #include #include #include #include #include "type_depository.hpp" #include //models: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //end models //#include using namespace std; using namespace opt_utilities; static const 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_opt_method(dopt::powell_method()); dopt::chisq cq; dopt::leastsq lsq; // cq.verbose(true); fit.set_statistic(cq); } }; std::vector model_names; void regist_model(const dopt::model& m,const char* addr) { if(find(model_names.begin(),model_names.end(),m.get_type_name())!=model_names.end()) { cerr<(),"lin1d"); } }_initializer; extern "C" { int 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 1; } fit_space_map.erase(iter); return 0; } int 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 1; } // 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); return 0; } int 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"< p(opt_utilities::get_model,std::string>(model_name)); iter->second.fit.set_model(*p); return 0; } catch(opt_exception& e) { //cout<::iterator iter=fit_space_map.find(nfit); cerr<<"pname="<second.fit.set_param_value(pname,value); return 0; } int freeze_param_(const int& nfit,const char* pname) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { return 1; } opt_utilities::freeze_param > fp(pname); try { dynamic_cast >& >(iter->second.fit.get_param_modifier())+=fp; return 0; } catch(opt_exception& e) { (void)e; iter->second.fit.set_param_modifier(fp); return 0; } return 0; } int thraw_param_(const int& nfit,const char* pname) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { return 1; } opt_utilities::freeze_param > fp(pname); try { dynamic_cast >& >(iter->second.fit.get_param_modifier())-=fp; } catch(opt_exception& e) { (void)e; //iter->second.fit.set_param_modifier(fp); } return 0; } int perform_fit_(const int& nfit) { map::iterator iter=fit_space_map.find(nfit); if(iter==fit_space_map.end()) { return 1; } iter->second.fit.fit(); return 0; } int 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); return 0; } }