31 namespace Test_RandomNumbers_SFMT {
32 const std::string
test_name =
"RandomNumbers.SFMT.Uniform";
36 const std::string filename_input =
"test_RandomNumbers_SFMT_Uniform.yaml";
42 #ifdef USE_TESTMANAGER_AUTOREGISTER
60 const int Nseed = params_test.
get_int(
"number_of_seeds");
61 const int iseed_base = params_test.
get_int(
"int_seed_base");
62 const int Nrand = params_test.
get_int(
"number_of_samples");
63 const string str_vlevel = params_test.
get_string(
"verbose_level");
65 const bool do_check = params_test.
is_set(
"expected_result");
66 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
92 for (
int iseed = 0; iseed < Nseed; ++iseed) {
93 int iseed2 = iseed_base + iseed;
95 RandomNumbers_SFMT rand(iseed2);
98 for (
int i = 0; i < Nrand; ++i) {
99 double rand1 = rand.get();
100 double rand2 = rand.get();
101 double r = rand1 * rand1 + rand2 * rand2;
103 if (r < 1.0) { ++Npi; }
107 double pi_exp = (4.0 * Npi) / Nrand;
110 t2 += pi_exp * pi_exp;
116 const double api = t1 / (double)Nseed;
117 const double vpi = t2 / (double)Nseed - api * api;
118 const double dpi = sqrt(vpi);
119 const double epi = dpi / sqrt((
double)Nseed - 1);
121 const double pi = 3.141592653589793;
128 const double result = api;
142 #endif // USE_SFMTLIB