Bridge++  Ver. 2.0.2
test_HotStart_Eigenvalue.cpp
Go to the documentation of this file.
1 
14 #include "test.h"
15 
16 #include "IO/gaugeConfig.h"
17 
18 #include "Tools/eigen_QR_Cmplx.h"
20 
21 //====================================================================
23 
30 namespace Test_HotStart {
31  const std::string test_name = "HotStart.Eigenvalue";
32 
33  //- test-private parameters
34  namespace {
35  const std::string filename_input = "test_HotStart_Eigenvalue.yaml";
36  }
37 
38  //- prototype declaration
39  int eigenvalue(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 eigenvalue(void)
56  {
57  const int Nc = CommonParameters::Nc();
58  const int Ndim = CommonParameters::Ndim();
59  const int Nvol = CommonParameters::Nvol();
60  const int NPE = CommonParameters::NPE();
61 
62  const double pi = 4.0 * atan(1.0);
63 
64  const Parameters params_all = ParameterManager::read(filename_input);
65 
66  const Parameters params_test = params_all.lookup("Test_HotStart");
67 
68  const string str_vlevel = params_test.get_string("verbose_level");
69 
70  const bool do_check = params_test.is_set("expected_result");
71  const double expected_result = do_check ? params_test.get_double("expected_result") : 0.0;
72 
73  const Bridge::VerboseLevel vl = vout.set_verbose_level(str_vlevel);
74 
75 
76  // #### Set up a gauge configuration ####
77  Field_G U(Nvol, Ndim);
78 
79  const int i_seed_noise = 1234567;
80  RandomNumbers_Mseries rand(i_seed_noise);
81 
82  U.set_random(&rand);
83 
84 
85  // #### object setup #####
86  Timer timer(test_name);
87 
88 
89  // #### Execution main part ####
90  timer.start();
91 
92  double av = 0.0;
93  double va = 0.0;
94  Eigen_QR_Cmplx eigen_qr(Nc);
95  std::valarray<double> vec(2 * Nc);
96 
97  for (int site = 0; site < Nvol; ++site) {
98  for (int mu = 0; mu < Ndim; ++mu) {
99  vec = eigen_qr.solve(U.ptr(0, site, mu));
100  for (int icolor = 0; icolor < Nc; ++icolor) {
101  double arg = atan2(vec[2 * icolor + 1], vec[2 * icolor]);
102 
103  vout.detailed(vl, "%10.8f\n", arg);
104 
105  av += arg;
106  va += arg * arg;
107  }
108  }
109  }
110 
111  const double av_all = Communicator::reduce_sum(av);
112  const double va_all = Communicator::reduce_sum(va);
113 
114  av = av_all / Nvol / NPE / Ndim / Nc;
115  va = va_all / Nvol / NPE / Ndim / Nc - av * av;
116 
117  va = sqrt(va);
118 
119  vout.general(vl, "\n");
120  vout.general(vl, "Random SU(%d):\n", Nc);
121  // vout.general(vl, " # of eigenvalue = %10d\n", Nvol * NPE * Ndim * Nc);
122  vout.general(vl, " ave = %23.16e\n", av);
123  vout.general(vl, " var = %23.16e\n", va);
124  vout.general(vl, " var(expected) = %23.16e\n", pi / sqrt(3.0));
125 
126  const double result = av;
127 
128  timer.report();
129 
130 
131  if (do_check) {
132  return Test::verify(result, expected_result);
133  } else {
134  vout.detailed(vl, "check skipped: expected_result not set.\n\n");
135  return EXIT_SKIP;
136  }
137  }
138 } // namespace Test_HotStart
Test::verify
int verify(const double result, const double expected, double eps)
Definition: test.cpp:27
randomNumbers_Mseries.h
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
Bridge::BridgeIO::detailed
void detailed(const char *format,...)
Definition: bridgeIO.cpp:219
gaugeConfig.h
Eigen_QR_Cmplx
Definition: eigen_QR_Cmplx.h:23
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Eigen_QR_Cmplx::solve
std::valarray< double > solve(const double *matrix)
Definition: eigen_QR_Cmplx.cpp:19
Test_HotStart::test_name
const std::string test_name
Definition: test_HotStart_Determinant.cpp:31
Timer
Definition: timer.h:31
Communicator::reduce_sum
static int reduce_sum(int count, dcomplex *recv_buf, dcomplex *send_buf, int pattern=0)
make a global sum of an array of dcomplex over the communicator. pattern specifies the dimensions to ...
Definition: communicator.cpp:263
Timer::start
void start()
Definition: timer.cpp:44
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
RandomNumbers_Mseries
Random number generator base on M-series.
Definition: randomNumbers_Mseries.h:46
test.h
eigen_QR_Cmplx.h
ParameterManager::read
static void read(const std::string &params_file, Parameters &params)
Definition: parameterManager.cpp:33
Parameters::get_double
double get_double(const string &key) const
Definition: parameters.cpp:175
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
EXIT_SKIP
#define EXIT_SKIP
Definition: test.h:17
Field::ptr
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Parameters::is_set
bool is_set(const string &key) const
Definition: parameters.cpp:525
Test_HotStart::eigenvalue
int eigenvalue(void)
Definition: test_HotStart_Eigenvalue.cpp:55
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
Test_HotStart
Test of hot start.
Definition: test_HotStart_Determinant.cpp:30
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Field_G::set_random
void set_random(RandomNumbers *rand)
Definition: field_G_imp.cpp:57
Parameters::lookup
Parameters lookup(const string &key) const
Definition: parameters.h:79
Timer::report
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
Definition: timer.cpp:128
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
TestManager::RegisterTest
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69