From c46b9282648442bcfb966bccc1f0736ea7959b78 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Wed, 1 Sep 2010 15:09:06 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@135 ed2142bd-67ad-457f-ba7c-d818d4011675 --- interface/opt.cc | 302 ++++++++++++++++++++++++++++--------------------------- interface/opt.h | 22 ++-- 2 files changed, 166 insertions(+), 158 deletions(-) diff --git a/interface/opt.cc b/interface/opt.cc index f122e2a..49113a1 100644 --- a/interface/opt.cc +++ b/interface/opt.cc @@ -76,157 +76,165 @@ public: 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); + int alloc_fit_(int& n) + { + n=0; + for(int i=1;i p(opt_utilities::get_model,std::string>(model_name)); - iter->second.fit.set_model(*p); - } - catch(opt_exception& e) + + int free_fit_(const int& n) { - //cout<::iterator iter=fit_space_map.find(n); + if(iter==fit_space_map.end()) + { + return 1; + } + fit_space_map.erase(iter); + return 0; } -} - -void set_param_(const int& nfit,const char* pname,const double& value) -{ - map::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) - { - (void)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) - { - (void)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); -} - - - + 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; + } } diff --git a/interface/opt.h b/interface/opt.h index e9c3221..a74d693 100644 --- a/interface/opt.h +++ b/interface/opt.h @@ -1,6 +1,6 @@ #ifndef OPT_H #define OPT_H -#define F77 +//#define F77 #ifdef F77 #define alloc_fit_ alloc_fit__ #define free_fit_ free_fit__ @@ -8,22 +8,22 @@ #define set_model_ set_model__ #define set_param_ set_param__ #define freeze_param_ freeze_param__ -#define thaw_param_ thaw_param__ +#define thraw_param_ thraw_param__ #define perform_fit_ perform_fit__ #define get_param_ get_param__ #endif extern "C" { - void alloc_fit_(int&); - void free_fit_(const int& nxc); - void load_data_(const int& nfit,const int& ndatas,double* x,double* y,double* yl,double* yu=0,double* xl=0,double* xu=0); - void set_model_(const int& nfit,const char* model_name); - void set_param_(const int& nfit,const char* param_name,const double& value); - void freeze_param_(const int& nfit,const char* param_name); - void thraw_param_(const int& nfit,const char* param_name); - void perform_fit_(const int& nfit); - void get_param_(const int& nfit,double& r,const char* param_name); + int alloc_fit_(int&); + int free_fit_(const int& nxc); + int load_data_(const int& nfit,const int& ndatas,double* x,double* y,double* yl,double* yu=0,double* xl=0,double* xu=0); + int set_model_(const int& nfit,const char* model_name); + int set_param_(const int& nfit,const char* param_name,const double& value); + int freeze_param_(const int& nfit,const char* param_name); + int thraw_param_(const int& nfit,const char* param_name); + int perform_fit_(const int& nfit); + int get_param_(const int& nfit,double& r,const char* param_name); } #endif -- cgit v1.2.2