From 7c0296b99989ac0e177a3e07e2aa40e8eb96f50c Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Tue, 25 Jan 2011 16:52:29 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@166 ed2142bd-67ad-457f-ba7c-d818d4011675 --- interface/perform_fit.hpp | 42 +++++++++++++++++++++++++++++ interface/type_depository.hpp | 62 +++++++++++++++++++++---------------------- 2 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 interface/perform_fit.hpp (limited to 'interface') diff --git a/interface/perform_fit.hpp b/interface/perform_fit.hpp new file mode 100644 index 0000000..5ae4e6d --- /dev/null +++ b/interface/perform_fit.hpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace opt_utilities +{ + + template + void perform_fit(const char* model_name, + const char* method_name, + const char* statistic_name, + const datat_set& ds, + const char* froze_parameters + ) + { + fitter fit; + fit.load_data(ds); + const statistic* pstat=get_statistic(statistic_name); + fit.set_statistic(*pstat); + const opt_method* popm=get_opt_method(method_name); + fit.set_opt_method(*popm); + const model* pmo=get_model(model_name); + fit.set_model(*pmo); + fit.fit(); + } + + +} diff --git a/interface/type_depository.hpp b/interface/type_depository.hpp index 6a53edc..d0e0bfb 100644 --- a/interface/type_depository.hpp +++ b/interface/type_depository.hpp @@ -122,7 +122,7 @@ namespace opt_utilities } template - void fetch_func_obj(func_obj* &fo,std::string cname,fetch_direction dir=in) + void fetch_func_obj(const func_obj* &fo,std::string cname,fetch_direction dir=in) { static std::map > >pm; typename std::map* result=it->second; - fo=result->clone(); + fo=result; } } else if(dir==in) @@ -152,14 +152,14 @@ namespace opt_utilities template void register_func_obj(const func_obj& fo) { - func_obj* pfo=const_cast*>(&fo); + const func_obj* pfo=&fo; fetch_func_obj(pfo,fo.get_type_name(),in); } template - func_obj* get_func_obj(std::string cname) + const func_obj* get_func_obj(std::string cname) { - func_obj* pom; + const func_obj* pom; fetch_func_obj(pom,cname,out); return pom; } @@ -172,7 +172,7 @@ namespace opt_utilities } template - void fetch_opt_method(opt_method* &fo,std::string cname,fetch_direction dir) + void fetch_opt_method(const opt_method* &fo,std::string cname,fetch_direction dir) { static std::map > > pm; typename std::map* result=it->second; - fo=result->clone(); + fo=result; } } else if(dir==in) @@ -201,14 +201,14 @@ namespace opt_utilities template void register_opt_method(const opt_method& fo) { - opt_method* pfo=const_cast*>(&fo); + const opt_method* pfo=&fo; fetch_opt_method(pfo,fo.get_type_name(),in); } template - opt_method* get_opt_method(std::string cname) + const opt_method* get_opt_method(std::string cname) { - opt_method* pom; + const opt_method* pom; fetch_opt_method(pom,cname,out); return pom; } @@ -221,7 +221,7 @@ namespace opt_utilities template - void fetch_statistic(statistic* &fo,std::string cname,fetch_direction dir) + void fetch_statistic(const statistic* &fo,std::string cname,fetch_direction dir) { static std::map > > pm; typename std::map* result=it->second; - fo=result->clone(); + fo=result; } } else if(dir==in) { //pm.insert(cname,fo->clone()); pm[cname]=holder >(fo->clone()); - } + } } template void register_statistic(const statistic& fo) { - statistic* pfo=const_cast*>(&fo); + const statistic* pfo=&fo; fetch_statistic(pfo,fo.get_type_name(),in); } template - statistic* get_statistic(std::string cname) + const statistic* get_statistic(std::string cname) { - statistic* pst; + const statistic* pst; fetch_statistic(pst,cname,out); return pst; } @@ -269,7 +269,7 @@ namespace opt_utilities } template - void fetch_param_modifier(param_modifier* &fo,std::string cname,fetch_direction dir) + void fetch_param_modifier(const param_modifier* &fo,std::string cname,fetch_direction dir) { static std::map > > pm; typename std::map* result=it->second; - fo=result->clone(); + fo=result; } } else if(dir==in) @@ -298,14 +298,14 @@ namespace opt_utilities template void register_param_modifier(const param_modifier& fo) { - param_modifier* pfo=const_cast*>(&fo); + const param_modifier* pfo=&fo; fetch_param_modifier(pfo,fo.get_type_name(),in); } template - param_modifier* get_param_modifier(std::string cname) + const param_modifier* get_param_modifier(std::string cname) { - param_modifier* ppm; + const param_modifier* ppm; fetch_param_modifier(ppm,cname,out); return ppm; } @@ -318,7 +318,7 @@ namespace opt_utilities } template - void fetch_data_set(data_set* &fo,std::string cname,fetch_direction dir) + void fetch_data_set(const data_set* &fo,std::string cname,fetch_direction dir) { static std::map > > pm; typename std::map* result=it->second; - fo=result->clone(); + fo=result; } } else if(dir==in) @@ -347,14 +347,14 @@ namespace opt_utilities template void register_data_set(const data_set& fo) { - data_set* pfo=const_cast*>(&fo); + const data_set* pfo=&fo; fetch_data_set(pfo,fo.get_type_name(),in); } template - data_set* get_data_set(std::string cname) + const data_set* get_data_set(std::string cname) { - data_set* pds; + const data_set* pds; fetch_data_set(pds,cname,out); return pds; } @@ -370,7 +370,7 @@ namespace opt_utilities template - void fetch_model(model* &fo,std::string cname,fetch_direction dir) + void fetch_model(const model* &fo,std::string cname,fetch_direction dir) { static std::map > > pm; typename std::map* result=it->second; - fo=result->clone(); + fo=result; } } else if(dir==in) @@ -398,14 +398,14 @@ namespace opt_utilities template void register_model(const model& fo) { - model* pfo=const_cast*>(&fo); + const model* pfo=&fo; fetch_model(pfo,fo.get_type_name(),in); } template - model* get_model(std::string cname) + const model* get_model(std::string cname) { - model* pds; + const model* pds; fetch_model(pds,cname,out); return pds; } -- cgit v1.2.2