27 namespace Test_Rational {
32 const std::string filename_input =
"test_Rational_Approx.yaml";
33 const std::string filename_output =
"stdout";
35 class Parameters_Test_Rational :
public Parameters {
37 Parameters_Test_Rational()
39 Register_string(
"verbose_level",
"NULL");
41 Register_double(
"expected_result", 0.0);
49 #ifdef USE_TESTMANAGER_AUTOREGISTER
51 #if defined(USE_GROUP_SU2)
66 Parameters *params_test =
new Parameters_Test_Rational;
74 params_manager.
read_params(filename_input, params_all);
76 const string str_vlevel = params_test->
get_string(
"verbose_level");
78 const bool do_check = params_test->
is_set(
"expected_result");
79 const double expected_result = do_check ? params_test->
get_double(
"expected_result") : 0.0;
81 const int n_exp = params_rational->
get_int(
"exponent_numerator");
82 const int d_exp = params_rational->
get_int(
"exponent_denominator");
83 const double x_min = params_rational->
get_double(
"lower_bound");
84 const double x_max = params_rational->
get_double(
"upper_bound");
85 const int Npoint = params_rational->
get_int(
"number_of_partitions");
90 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
110 double Dx = (x_max - x_min) / Npoint;
111 double p_exp = ((double)n_exp) / ((double)d_exp);
113 for (
int j = 0; j < Npoint + 1; ++j) {
114 double y1 = rational.
func(x);
115 double y2 = pow(x, p_exp);
117 vout.
general(vl,
"x,rational,x^(n/d) = %12.8f %12.8f %12.8f \n", x, y1, y2);
129 delete params_rational;
138 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
Determionation of coefficients of rational approximation.
const std::string test_name
void read_params(const std::string ¶ms_file, Parameters *params)
read parameters from file.
void detailed(const char *format,...)
void general(const char *format,...)
void set_parameters(const Parameters ¶ms)
int get_int(const string &key) const
static bool RegisterTest(const std::string &key, const Test_function func)
bool is_set(const string &) const
double get_double(const string &key) const
void Register_Parameters(const string &, Parameters *const)
Parameter manager with YAML parser.
int verify(const double expected, const double result)
string get_string(const string &key) const
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
static VerboseLevel set_verbose_level(const std::string &str)