Bridge++  Version 1.4.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 "Tests/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  int Nc = CommonParameters::Nc();
59  int Nvol = CommonParameters::Nvol();
60  int Ndim = CommonParameters::Ndim();
61 
62  Parameters params_all = ParameterManager::read(filename_input);
63 
64  Parameters params_test = params_all.lookup("Test_HotStart");
65 
66  const string str_vlevel = params_test.get_string("verbose_level");
67 
68  const bool do_check = params_test.is_set("expected_result");
69  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
70 
72 
73 
74  // #### Set up a gauge configuration ####
75  unique_ptr<Field_G> U(new Field_G(Nvol, Ndim));
76 
77  int i_seed_noise = 1234567;
78  unique_ptr<RandomNumbers> rand(new RandomNumbers_Mseries(i_seed_noise));
79  U->set_random(rand);
80 
81 
82  // #### object setup #####
83  unique_ptr<Timer> timer(new Timer(test_name));
84 
85 
86  // #### Execution main part ####
87  timer->start();
88 
89  Mat_SU_N link(Nc);
90 
91  double re_av = 0.0;
92  double re_va = 0.0;
93  double im_av = 0.0;
94  double im_va = 0.0;
95 
96  Decompose_LUP_Cmplx lup(Nc);
97  for (int site = 0; site < Nvol; ++site) {
98  for (int mu = 0; mu < Ndim; ++mu) {
99  lup.set_matrix(U->ptr(0, site, mu));
100 
101  dcomplex det = lup.determinant();
102 
103  re_av += real(det);
104  re_va += real(det) * real(det);
105  im_av += imag(det);
106  im_va += imag(det) * imag(det);
107  }
108  }
109 
110  double re_av_all = Communicator::reduce_sum(re_av);
111  double re_va_all = Communicator::reduce_sum(re_va);
112  double im_av_all = Communicator::reduce_sum(im_av);
113  double im_va_all = Communicator::reduce_sum(im_va);
114 
115  int Nlink = CommonParameters::Lvol() * Ndim;
116 
117  re_av = re_av_all / Nlink;
118  im_av = im_av_all / Nlink;
119  re_va = re_va_all / Nlink - re_av * re_av;
120  im_va = im_va_all / Nlink - im_av * im_av;
121 
122  re_va = sqrt(re_va);
123  im_va = sqrt(im_va);
124 
125  vout.general(vl, "\n");
126  vout.general(vl, "Random SU(%d):\n", Nc);
127  vout.general(vl, " number of matrix = %10d\n", Nlink);
128  vout.general(vl, " ave Re(det) = %23.16e\n", re_av);
129  vout.general(vl, " var Re(det) = %23.16e\n", re_va);
130  vout.general(vl, " ave Im(det) = %23.16e\n", im_av);
131  vout.general(vl, " var Im(det) = %23.16e\n", im_va);
132 
133  double result = re_av;
134 
135  timer->report();
136 
137 
138  if (do_check) {
139  return Test::verify(result, expected_result);
140  } else {
141  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
142  return EXIT_SKIP;
143  }
144  }
145 } // namespace Test_HotStart
#define EXIT_SKIP
Definition: test.h:17
Random number generator base on M-series.
BridgeIO vout
Definition: bridgeIO.cpp:495
void detailed(const char *format,...)
Definition: bridgeIO.cpp:212
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:142
void general(const char *format,...)
Definition: bridgeIO.cpp:195
const std::string test_name
Class for parameters.
Definition: parameters.h:46
static int Lvol()
void set_random(RandomNumbers *rand)
Definition: field_G_imp.cpp:62
Parameters lookup(const string &key) const
Definition: parameters.h:78
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:70
bool is_set(const string &key) const
Definition: parameters.cpp:396
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
Definition: checker.cpp:18
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:116
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