29 namespace Test_RandomNumbers_MT19937 {
30 const std::string
test_name =
"RandomNumbers.MT19937.Uniform";
34 const std::string filename_input =
"test_RandomNumbers_MT19937_Uniform.yaml";
40 #ifdef USE_TESTMANAGER_AUTOREGISTER
58 const int Nseed = params_test.
get_int(
"number_of_seeds");
59 const int iseed_base = params_test.
get_int(
"int_seed_base");
60 const int Nrand = params_test.
get_int(
"number_of_samples");
61 const string str_vlevel = params_test.
get_string(
"verbose_level");
63 const bool do_check = params_test.
is_set(
"expected_result");
64 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
72 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
85 vout.
general(vl,
" number of samples = %10d\n", Nrand);
91 for (
int iseed = 0; iseed < Nseed; ++iseed) {
92 int iseed2 = iseed_base + iseed;
97 for (
int i = 0; i < Nrand; ++i) {
98 double rand1 = rand->
get();
99 double rand2 = rand->
get();
100 double r = rand1 * rand1 + rand2 * rand2;
102 if (r < 1.0) { ++Npi; }
106 double pi_exp = (4.0 * Npi) / Nrand;
109 t2 += pi_exp * pi_exp;
112 vout.
general(vl,
" %10d %14.10f\n", iseed2, pi_exp);
115 const double api = t1 / (double)Nseed;
116 const double vpi = t2 / (double)Nseed - api * api;
117 const double dpi = sqrt(vpi);
118 const double epi = dpi / sqrt((
double)Nseed - 1);
120 const double pi = 3.141592653589793;
127 const double result = api;
136 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
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)
static VerboseLevel set_verbose_level(const std::string &str)
int uniform_calc_pi(void)