29 namespace Test_RandomNumbers_Mseries {
30 const std::string
test_name =
"RandomNumbers.Mseries.Uniform";
34 const std::string filename_input =
"test_RandomNumbers_Mseries_Uniform.yaml";
40 #ifdef USE_TESTMANAGER_AUTOREGISTER
58 int Nseed = params_test.
get_int(
"number_of_seeds");
59 int iseed_base = params_test.
get_int(
"int_seed_base");
60 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);
90 for (
int iseed = 0; iseed < Nseed; ++iseed) {
91 int iseed2 = iseed_base + iseed;
96 for (
int i = 0; i < Nrand; ++i) {
97 double rand1 = rand->
get();
98 double rand2 = rand->
get();
99 double r = rand1 * rand1 + rand2 * rand2;
100 if (r < 1.0) { ++Npi; }
104 double pi_exp = (4.0 * Npi) / Nrand;
107 t2 += pi_exp * pi_exp;
110 vout.
general(vl,
" %10d %14.10f\n", iseed2, pi_exp);
113 double api = t1 / (double)Nseed;
114 double vpi = t2 / (double)Nseed - api * api;
115 double dpi = sqrt(vpi);
116 double epi = dpi / sqrt((
double)Nseed - 1);
118 double pi = 3.141592653589793;
134 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
int uniform_calc_pi(void)
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)