Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_HotStart_Determinant.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "IO/gaugeConfig.h"
17 
20 
21 //====================================================================
23 
30 namespace Test_HotStart {
31  const std::string test_name = "HotStart.Determinant";
32 
33  //- test-private parameters
34  namespace {
35  const std::string filename_input = "test_HotStart_Determinant.yaml";
36  }
37 
38  //- prototype declaration
39  int determinant(void);
40 
41 #ifdef USE_TESTMANAGER_AUTOREGISTER
42  namespace {
43 #if defined(USE_GROUP_SU2)
44  // Nc=2 is not available.
45 #else
46  static const bool is_registered = TestManager::RegisterTest(
47  test_name,
49  );
50 #endif
51  }
52 #endif
53 
54  //====================================================================
55  int determinant(void)
56  {
57  // ##### parameter setup #####
58  const int Nc = CommonParameters::Nc();
59  const int Ndim = CommonParameters::Ndim();
60  const int Nvol = CommonParameters::Nvol();
61  const int NPE = CommonParameters::NPE();
62 
63  const Parameters params_all = ParameterManager::read(filename_input);
64 
65  const Parameters params_test = params_all.lookup("Test_HotStart");
66 
67  const string str_vlevel = params_test.get_string("verbose_level");
68 
69  const bool do_check = params_test.is_set("expected_result");
70  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
71 
72  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
73 
74 
75  // #### Set up a gauge configuration ####
76  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
77 
78  const int i_seed_noise = 1234567;
79  unique_ptr<RandomNumbers> rand(new RandomNumbers_Mseries(i_seed_noise));
80  U->set_random(rand);
81 
82 
83  // #### object setup #####
84  const unique_ptr<Timer> timer(new Timer(test_name));
85 
86 
87  // #### Execution main part ####
88  timer->start();
89 
90  double re_av = 0.0;
91  double re_va = 0.0;
92  double im_av = 0.0;
93  double im_va = 0.0;
94 
95  Decompose_LUP_Cmplx lup(Nc);
96  for (int site = 0; site < Nvol; ++site) {
97  for (int mu = 0; mu < Ndim; ++mu) {
98  lup.set_matrix(U->ptr(0, site, mu));
99 
100  dcomplex det = lup.determinant();
101 
102  re_av += real(det);
103  re_va += real(det) * real(det);
104  im_av += imag(det);
105  im_va += imag(det) * imag(det);
106  }
107  }
108 
109  const double re_av_all = Communicator::reduce_sum(re_av);
110  const double re_va_all = Communicator::reduce_sum(re_va);
111  const double im_av_all = Communicator::reduce_sum(im_av);
112  const double im_va_all = Communicator::reduce_sum(im_va);
113 
114  re_av = re_av_all / Nvol / NPE / Ndim;
115  im_av = im_av_all / Nvol / NPE / Ndim;
116  re_va = re_va_all / Nvol / NPE / Ndim - re_av * re_av;
117  im_va = im_va_all / Nvol / NPE / Ndim - im_av * im_av;
118 
119  re_va = sqrt(re_va);
120  im_va = sqrt(im_va);
121 
122  vout.general(vl, "\n");
123  vout.general(vl, "Random SU(%d):\n", Nc);
124  // vout.general(vl, " number of matrix = %10d\n", Nvol * NPE * Ndim);
125  vout.general(vl, " ave Re(det) = %23.16e\n", re_av);
126  vout.general(vl, " var Re(det) = %23.16e\n", re_va);
127  vout.general(vl, " ave Im(det) = %23.16e\n", im_av);
128  vout.general(vl, " var Im(det) = %23.16e\n", im_va);
129 
130  const double result = re_av;
131 
132  timer->report();
133 
134 
135  if (do_check) {
136  return Test::verify(result, expected_result);
137  } else {
138  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
139  return EXIT_SKIP;
140  }
141  }
142 } // 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
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
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
static void read(const std::string &params_file, Parameters &params)
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
Bridge::VerboseLevel vl
VerboseLevel
Definition: bridgeIO.h:42
void set_matrix(const double *mat)
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
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131