Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_HotStart_Unitary.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "IO/gaugeConfig.h"
17 
19 
20 //====================================================================
22 
29 namespace Test_HotStart {
30  const std::string test_name = "HotStart.Unitary";
31 
32  //- test-private parameters
33  namespace {
34  const std::string filename_input = "test_HotStart_Unitary.yaml";
35  }
36 
37  //- prototype declaration
38  int unitary(void);
39 
40 #ifdef USE_TESTMANAGER_AUTOREGISTER
41  namespace {
42 #if defined(USE_GROUP_SU2)
43  // Nc=2 is not available.
44 #else
45  static const bool is_registered = TestManager::RegisterTest(
46  test_name,
47  unitary
48  );
49 #endif
50  }
51 #endif
52 
53  //====================================================================
54  int unitary(void)
55  {
56  const int Nc = CommonParameters::Nc();
57  const int Ndim = CommonParameters::Ndim();
58  const int Nvol = CommonParameters::Nvol();
59  const int NPE = CommonParameters::NPE();
60 
61  const Parameters params_all = ParameterManager::read(filename_input);
62 
63  const Parameters params_test = params_all.lookup("Test_HotStart");
64 
65  const string str_vlevel = params_test.get_string("verbose_level");
66 
67  const bool do_check = params_test.is_set("expected_result");
68  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
69 
70  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
71 
72 
73  // #### Set up a gauge configuration ####
74  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
75 
76  const int i_seed_noise = 1234567;
77  unique_ptr<RandomNumbers> rand(new RandomNumbers_Mseries(i_seed_noise));
78  U->set_random(rand);
79 
80 
81  // #### object setup #####
82  const unique_ptr<Timer> timer(new Timer(test_name));
83 
84 
85  // #### Execution main part ####
86  timer->start();
87 
88  Mat_SU_N link(Nc);
89  Mat_SU_N unity(Nc);
90 
91  double av = 0;
92  for (int site = 0; site < Nvol; ++site) {
93  for (int mu = 0; mu < Ndim; ++mu) {
94  U->mat(link, site, mu);
95  unity.unit();
96  unity *= -1.0;
97 
98  // |UU^\dag - I|
99  unity.multadd_nd(link, link);
100  av += sqrt(unity.norm2());
101  }
102  }
103 
104  const double av_all = Communicator::reduce_sum(av);
105 
106  vout.general(vl, "\n");
107  vout.general(vl, "Random SU(%d):\n", Nc);
108  // vout.general(vl, " number of matrix = %10d\n", Nvol * NPE * Ndim);
109  vout.general(vl, " ave |UU^dag - I| = %23.16e\n", av_all / Nvol / NPE / Ndim);
110 
111  const double result = av_all / Nvol / NPE / Ndim;
112 
113  timer->report();
114 
115 
116  if (do_check) {
117  return Test::verify(result, expected_result);
118  } else {
119  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
120  return EXIT_SKIP;
121  }
122  }
123 } // namespace Test_HotStart
#define EXIT_SKIP
Definition: test.h:17
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:503
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
void general(const char *format,...)
Definition: bridgeIO.cpp:197
const std::string test_name
Class for parameters.
Definition: parameters.h:46
void set_random(RandomNumbers *rand)
Definition: field_G_imp.cpp:60
Parameters lookup(const string &key) const
Definition: parameters.h:79
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69
SU(N) gauge field.
Definition: field_G.h:38
double get_double(const string &key) const
Definition: parameters.cpp:175
bool is_set(const string &key) const
Definition: parameters.cpp:528
void start()
Definition: timer.cpp:44
void multadd_nd(const Mat_SU_N &u1, const Mat_SU_N &u2)
Definition: mat_SU_N.h:215
static void read(const std::string &params_file, Parameters &params)
double norm2()
Definition: mat_SU_N.h:155
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
Bridge::VerboseLevel vl
VerboseLevel
Definition: bridgeIO.h:42
Mat_SU_N & unit()
Definition: mat_SU_N.h:373
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...
Definition: timer.h:31
string get_string(const string &key) const
Definition: parameters.cpp:221
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
Definition: timer.cpp:128
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131