29 namespace Test_RandomNumbers_Mseries {
30 const std::string
test_name =
"RandomNumbers.Mseries.Gaussian";
34 const std::string filename_input =
"test_RandomNumbers_Mseries_Gaussian.yaml";
40 #ifdef USE_TESTMANAGER_AUTOREGISTER
58 const int iseed = params_test.
get_int(
"int_seed");
59 const int Nrand = params_test.
get_int(
"number_of_samples");
60 const string str_vlevel = params_test.
get_string(
"verbose_level");
62 const bool do_check = params_test.
is_set(
"expected_result");
63 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
70 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
86 for (
int i = 0; i < Nrand; ++i) {
87 rand->
gauss(rand1, rand2);
89 vr += rand1 * rand1 + rand2 * rand2;
92 av = av / (2.0 * Nrand);
93 vr = vr / (2.0 * Nrand) - av * av;
98 vout.
general(vl,
" number of samples = %10d\n", Nrand);
101 vout.
general(vl,
" variance(expect) = %10.8f\n", 1.0 / sqrt(2.0));
103 const double result = vr;
111 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
Random number generator base on M-series.
void detailed(const char *format,...)
void general(const char *format,...)
int get_int(const string &key) const
Parameters lookup(const string &key) const
static bool RegisterTest(const std::string &key, const Test_function func)
double get_double(const string &key) const
bool is_set(const string &key) const
const std::string test_name
static void read(const std::string ¶ms_file, Parameters ¶ms)
int verify(const double result, const double expected, double eps)
string get_string(const string &key) const
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
void gauss(double &rand1, double &rand2)
static VerboseLevel set_verbose_level(const std::string &str)