31 namespace Test_RandomNumbers {
32 const std::string
test_name =
"RandomNumbers.Field";
45 return rand_field(
"test_RandomNumbers_MT19937_Field_Gaussian.yaml");
51 return rand_field(
"test_RandomNumbers_MT19937_Field_U1.yaml");
57 return rand_field(
"test_RandomNumbers_MT19937_Field_Z2.yaml");
63 return rand_field(
"test_RandomNumbers_Mseries_Field_Gaussian.yaml");
69 return rand_field(
"test_RandomNumbers_Mseries_Field_U1.yaml");
75 return rand_field(
"test_RandomNumbers_Mseries_Field_Z2.yaml");
80 int rand_field_SFMT_Gaussian()
82 return rand_field(
"test_RandomNumbers_SFMT_Field_Gaussian.yaml");
86 int rand_field_SFMT_U1()
88 return rand_field(
"test_RandomNumbers_SFMT_Field_U1.yaml");
92 int rand_field_SFMT_Z2()
94 return rand_field(
"test_RandomNumbers_SFMT_Field_Z2.yaml");
99 #ifdef USE_TESTMANAGER_AUTOREGISTER
102 "RandomNumbers.MT19937.Field.Gaussian",
107 "RandomNumbers.MT19937.Field.U1",
112 "RandomNumbers.MT19937.Field.Z2",
118 "RandomNumbers.Mseries.Field.Gaussian",
123 "RandomNumbers.Mseries.Field.U1",
128 "RandomNumbers.Mseries.Field.Z2",
134 "RandomNumbers.SFMT.Field.Gaussian",
135 rand_field_SFMT_Gaussian
139 "RandomNumbers.SFMT.Field.U1",
144 "RandomNumbers.SFMT.Field.Z2",
158 const string str_rand_type = params_test.
get_string(
"random_number_type");
159 const string str_noise_type = params_test.
get_string(
"noise_type");
160 const int iseed = params_test.
get_int(
"int_seed");
161 const string str_vlevel = params_test.
get_string(
"verbose_level");
163 const bool do_check = params_test.
is_set(
"expected_result");
164 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
169 vout.
general(vl,
" rand_type = %s\n", str_rand_type.c_str());
170 vout.
general(vl,
" noise_type = %s\n", str_noise_type.c_str());
172 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
189 Field v(Nin, Nvol, Nex);
196 const int size = v.
size();
197 for (
int i = 0; i < size; ++i) {
199 vr += v.
cmp(i) * v.
cmp(i);
206 av = av_all / Nvol / NPE / Nin / Nex;
207 vr = vr_all / Nvol / NPE / Nin / Nex - av * av;
212 vout.
general(vl,
" number of samples = %10d\n", size);
215 vout.
general(vl,
" variance(expect) = %10.8f\n", 1.0 / sqrt(2.0));
225 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
void detailed(const char *format,...)
int rand_field_MT19937_Z2()
void general(const char *format,...)
Container of Field-type object.
int rand_field_MT19937_Gaussian()
double cmp(const int jin, const int site, const int jex) const
int get_int(const string &key) const
int rand_field_Mseries_Z2()
int rand_field_Mseries_U1()
Parameters lookup(const string &key) const
static bool RegisterTest(const std::string &key, const Test_function func)
double get_double(const string &key) const
int rand_field_Mseries_Gaussian()
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)
virtual void lex_global(const std::string &, Field &)
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...
const std::string test_name
int rand_field_MT19937_U1()
string get_string(const string &key) const
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
int rand_field(const std::string &)
static VerboseLevel set_verbose_level(const std::string &str)