From 9457fdc792820f5fc3d80945e5e2d9dfc1b1f550 Mon Sep 17 00:00:00 2001 From: Laurent Belcour Date: Thu, 14 Nov 2013 14:50:58 +0100 Subject: [PATCH] Allowing to change the parametrization of the ABC model using command line argument --- sources/core/params.h | 3 ++- .../nonlinear_function_abc/function.cpp | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sources/core/params.h b/sources/core/params.h index 725fc27..4dc13d2 100644 --- a/sources/core/params.h +++ b/sources/core/params.h @@ -326,7 +326,8 @@ class parametrized else { std::cout << "<> an input parametrization is already defined: " << params::get_name(_in_param) << std::endl; - std::cout << "<> trying to change to: " << params::get_name(new_param) << std::endl; + std::cout << "<> changing to: " << params::get_name(new_param) << std::endl; + _in_param = new_param; } } diff --git a/sources/plugins/nonlinear_function_abc/function.cpp b/sources/plugins/nonlinear_function_abc/function.cpp index 1757323..0135155 100644 --- a/sources/plugins/nonlinear_function_abc/function.cpp +++ b/sources/plugins/nonlinear_function_abc/function.cpp @@ -143,6 +143,19 @@ void abc_function::bootstrap(const data* d, const arguments& args) _b[i] = 1.0; _c[i] = 1.0; } + + if(args.is_defined("param")) + { + setParametrization(params::parse_input(args["param"])); + } + else + { + setParametrization(params::COS_TH); + } + if(params::dimension(input_parametrization()) != 1) + { + std::cerr << "<> the parametrization specifed in the file for the ABC model is incorrect" << std::endl; + } } //! Load function specific files @@ -175,6 +188,19 @@ bool abc_function::load(std::istream& in) std::cerr << "<> parsing the stream. function name is not the next token." << std::endl; return false; } + + in >> token; + if(token.compare("#PARAM") != 0) + { + std::cerr << "<> parsing the stream. The #PARAM is not the next line defined." << std::endl; + return false; + } + in >> token; + setParametrization(params::parse_input(token)); + if(params::dimension(input_parametrization()) != 1) + { + std::cerr << "<> the parametrization specifed in the file for the ABC model is incorrect" << std::endl; + } // Parse the lobe for(int i=0; i<_nY; ++i) @@ -195,6 +221,7 @@ void abc_function::save_call(std::ostream& out, const arguments& args) const if(is_alta) { out << "#FUNC nonlinear_function_abc" << std::endl ; + out << "#PARAM " << params::get_name(input_parametrization()) << std::endl; for(int i=0; i<_nY; ++i) { -- GitLab