31 namespace Test_RandomNumbers_SFMT {
32 const std::string
test_name =
"RandomNumbers.SFMT.GaussianField";
36 const std::string filename_input =
"test_RandomNumbers_SFMT_GaussianField.yaml";
42 #ifdef USE_TESTMANAGER_AUTOREGISTER
60 int iseed = params_test.
get_int(
"int_seed");
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;
70 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
75 unique_ptr<RandomNumbers> rand(
new RandomNumbers_SFMT(iseed));
85 Field v(Nin, Nvol, Nex);
90 rand->gauss_lex_global(v);
93 for (
int i = 0; i < size; ++i) {
95 vr += v.cmp(i) * v.cmp(i);
104 av = av_all / global_size;
105 vr = vr_all / global_size - av * av;
109 vout.
general(vl,
"Gaussian distribution (Field):\n");
110 vout.
general(vl,
" number of samples = %10d\n", size);
113 vout.
general(vl,
" variance(expect) = %10.8f\n", 1.0 / sqrt(2.0));
119 printf(
"result = %24.20f\n", result);
125 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
130 #endif // USE_SFMTLIB
void detailed(const char *format,...)
void general(const char *format,...)
const std::string test_name
Container of Field-type object.
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
static void read(const std::string ¶ms_file, Parameters ¶ms)
int verify(const double result, const double expected, double eps)
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
string get_string(const string &key) const
static VerboseLevel set_verbose_level(const std::string &str)