44 namespace Test_Spectrum_CRSMatrix {
47 const std::string filename_input =
"test_Spectrum_CRSMatrix_Clover_Lexical.yaml";
54 const string& solution,
64 #ifdef USE_TESTMANAGER_AUTOREGISTER
69 #if defined(USE_GROUP_SU2)
73 "Spectrum.CRSMatrix.Clover_Lexical",
86 vout.
general(
"CRSMatrix test: node-parallel unsupported. skip.\n");
100 const string str_gconf_read = params_test.
get_string(
"gauge_config_type_input");
101 const string readfile = params_test.
get_string(
"config_filename_input");
102 const string matrix_file = params_test.
get_string(
"matrix_output");
103 const string source_file = params_test.
get_string(
"source_output");
104 const string solution_file = params_test.
get_string(
"solution_output");
105 const string str_vlevel = params_test.
get_string(
"verbose_level");
107 const bool do_check = params_test.
is_set(
"expected_result");
108 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
113 vout.
general(vl,
" gconf_read = %s\n", str_gconf_read.c_str());
114 vout.
general(vl,
" readfile = %s\n", readfile.c_str());
115 vout.
general(vl,
" matrix_output = %s\n", matrix_file.c_str());
116 vout.
general(vl,
" source_output = %s\n", source_file.c_str());
117 vout.
general(vl,
" solution_output = %s\n", solution_file.c_str());
118 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
130 vout.
crucial(vl,
"Error: Test_Spectrum_CRSMatrix: input parameters have not been set\n");
142 const double kappa = 0.12;
143 const double cSW = 1.0;
144 std::vector<int> boundary(Ndim);
151 params_c.
set_double(
"hopping_parameter", kappa);
152 params_c.
set_double(
"clover_coefficient", cSW);
154 params_c.
set_string(
"verbose_level", str_vlevel.c_str());
164 const int Niter = 100;
165 const int Nrestart = 40;
166 const double Stop_cond = 1.0e-28;
167 const bool use_init_guess =
false;
170 params_solver.
set_int(
"maximum_number_of_iteration", Niter);
171 params_solver.
set_int(
"maximum_number_of_restart", Nrestart);
172 params_solver.
set_double(
"convergence_criterion_squared", Stop_cond);
173 params_solver.
set_bool(
"use_initial_guess", use_init_guess);
174 params_solver.
set_string(
"verbose_level", str_vlevel.c_str());
179 std::vector<int> source_position(Ndim);
180 source_position[0] = 0;
181 source_position[1] = 0;
182 source_position[2] = 0;
183 source_position[3] = 0;
188 params_source.
set_string(
"verbose_level", str_vlevel.c_str());
193 std::vector<Field_F> sq(Nc * Nd);
194 for (
int idx = 0; idx < Nc * Nd; ++idx) {
198 for (
int ispin = 0; ispin < Nd; ++ispin) {
199 for (
int icolor = 0; icolor < Nc; ++icolor) {
200 int idx = icolor + Nc * ispin;
215 solver->
solve(xq, b2, Nconv, diff_CG);
216 vout.
general(vl,
" ispin = %2d icolor = %2d Nconv = %4d diff = %12.6e\n",
217 ispin, icolor, Nconv, diff_CG);
227 double yy = y.norm2();
230 sq[icolor + Nc * ispin] = xq;
243 const int icolor = 0;
247 source->
set(b, icolor, ispin);
249 fopr_crs2->set_mode(
"Ddag");
254 fopr_crs2->set_mode(
"DdagD");
255 solver_crs->
solve(xq, b2, Nconv, diff_CG);
256 vout.
general(vl,
" ispin = %2d icolor = %2d Nconv = %4d diff = %12.6e\n",
257 ispin, icolor, Nconv, diff_CG);
260 fopr_crs2->set_mode(
"D");
265 sq[icolor + Nc * ispin] = xq;
272 CRSsolver(solution_file, matrix_file, source_file, result);
278 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
void scal(Field &x, const double a)
scal(x, a): x = a * x
void detailed(const char *format,...)
void set_int_vector(const string &key, const vector< int > &value)
void general(const char *format,...)
virtual void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
void set_int(const string &key, const int value)
int solver(const std::string &)
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
Container of Field-type object.
Standard Conjugate Gradient solver algorithm.
Wilson-type fermion field.
virtual void set_parameters(const Parameters ¶ms)=0
Parameters lookup(const string &key) const
static bool RegisterTest(const std::string &key, const Test_function func)
void set_string(const string &key, const string &value)
void set_bool(const string &key, const bool value)
double get_double(const string &key) const
int CRSsolver(const string &solution, const string &matrix, const string &source, double &result)
virtual void set_parameters(const Parameters &)=0
int non_NULL(const std::string v)
bool is_set(const string &key) const
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
void write_text(const Field &f, const string &filename)
void crucial(const char *format,...)
static void read(const std::string ¶ms_file, Parameters ¶ms)
void read_file(Field_G *U, const string &filename)
void read_text(Field &f, const string &filename)
int verify(const double result, const double expected, double eps)
void set_double(const string &key, const double value)
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
void write_matrix(const std::string)
GaugeConfig class for file I/O of gauge configuration.
virtual void mult_dag(Field &, const Field &)
hermitian conjugate of mult(Field&, const Field&).
string get_string(const string &key) const
Fermion operator with CRS matrix format.
virtual void solve(Field &solution, const Field &source, int &Nconv, double &diff)=0
virtual void set_parameters(const Parameters &)=0
static VerboseLevel set_verbose_level(const std::string &str)
virtual void set(Field &, const int)=0