38 namespace Test_Eigensolver_Chebyshev {
39 const std::string
test_name =
"Eigensolver.Chebyshev";
43 const std::string filename_input =
"test_Eigensolver_Chebyshev.yaml";
49 #ifdef USE_TESTMANAGER_AUTOREGISTER
51 #if defined(USE_GROUP_SU2)
78 const Parameters params_irlanczos = params_all.
lookup(
"Eigensolver_Chebyshev");
80 const string str_gconf_status = params_test.
get_string(
"gauge_config_status");
81 const string str_gconf_read = params_test.
get_string(
"gauge_config_type_input");
82 const string readfile = params_test.
get_string(
"config_filename_input");
83 const string str_rand_type = params_test.
get_string(
"random_number_type");
84 const unsigned long seed = params_test.
get_unsigned_long(
"seed_for_random_number");
85 const string str_vlevel = params_test.
get_string(
"verbose_level");
87 const bool do_check = params_test.
is_set(
"expected_result");
88 const double expected_result = do_check ? params_test.
get_double(
"expected_result") : 0.0;
90 const string str_fopr_type = params_fopr.
get_string(
"fermion_type");
91 const string str_gmset_type = params_fopr.
get_string(
"gamma_matrix_type");
92 const string str_proj_type = params_proj.
get_string(
"projection_type");
93 const string str_smear_type = params_smear.
get_string(
"smear_type");
94 const string str_sortfield_type = params_irlanczos.
get_string(
"eigensolver_mode");
95 const int Nk = params_irlanczos.
get_int(
"number_of_wanted_eigenvectors");
96 const int Np = params_irlanczos.
get_int(
"number_of_working_eigenvectors");
97 const int Niter_eigen = params_irlanczos.
get_int(
"maximum_number_of_iteration");
98 const double Enorm_eigen = params_irlanczos.
get_double(
"convergence_criterion_squared");
99 const double Vthreshold = params_irlanczos.
get_double(
"threshold_value");
104 vout.
general(vl,
" gconf_status = %s\n", str_gconf_status.c_str());
105 vout.
general(vl,
" gconf_read = %s\n", str_gconf_read.c_str());
106 vout.
general(vl,
" readfile = %s\n", readfile.c_str());
107 vout.
general(vl,
" rand_type = %s\n", str_rand_type.c_str());
109 vout.
general(vl,
" vlevel = %s\n", str_vlevel.c_str());
110 vout.
general(vl,
" gmset_type = %s\n", str_gmset_type.c_str());
111 vout.
general(vl,
" proj_type = %s\n", str_proj_type.c_str());
112 vout.
general(vl,
" smear_type = %s\n", str_smear_type.c_str());
113 vout.
general(vl,
" sortfield_type = %s\n", str_sortfield_type.c_str());
132 if (str_gconf_status ==
"Continue") {
134 }
else if (str_gconf_status ==
"Cold_start") {
136 }
else if (str_gconf_status ==
"Hot_start") {
139 vout.
crucial(vl,
"Error at %s: unsupported gconf status \"%s\"\n",
test_name.c_str(), str_gconf_status.c_str());
165 const double Vthreshold_ch = fopr_ch->
mult(Vthreshold * Vthreshold);
166 vout.
general(vl,
"Vthreshold_ch = %12.6f\n", Vthreshold_ch);
170 eigen->
set_parameters(str_sortfield_type, Nk, Np, Niter_eigen, Enorm_eigen, Vthreshold_ch);
179 const int NFin = b2.
nin();
180 const int NFvol = b2.
nvol();
181 const int NFex = b2.
nex();
183 const int Nm = Nk + Np;
184 std::vector<double> TDa(Nm);
186 std::vector<Field> vk(Nm);
187 for (
int k = 0; k < Nm; ++k) {
188 vk[k].reset(NFin, NFvol, NFex);
193 eigen->
solve(TDa, vk, Nsbt, Nconv, (
Field)b2);
198 for (
int i = 0; i < Nsbt + 1; ++i) {
199 Field v(NFin, NFvol, NFex);
202 fopr_smear->
mult(v, vk[i]);
204 double vnum =
dot(vk[i], v);
205 double vden =
dot(vk[i], vk[i]);
206 double veig = vnum / vden;
209 axpy(v, -TDa[i], vk[i]);
210 double vv = v.
norm2();
212 vout.
general(vl,
"Eigenvalues: %4d %20.14f %10.4e %10.4e\n", i, TDa[i], vv, vden - 1.0);
215 const double result = TDa[0];
225 vout.
detailed(vl,
"check skipped: expected_result not set.\n\n");
Eigenvalue solver with Implicitly Restarted Lanczos algorithm.
void detailed(const char *format,...)
const std::string test_name
virtual void set_parameters(const Parameters ¶m)=0
double dot(const Field &y, const Field &x)
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...
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
Container of Field-type object.
void solve(std::vector< double > &TDa, std::vector< Field > &vk, int &Nsbt, int &Nconv, const Field &b)
virtual void set_parameters(const Parameters &)=0
int get_int(const string &key) const
int solve_chebyshev(void)
Wilson-type fermion field.
Parameters lookup(const string &key) const
static bool RegisterTest(const std::string &key, const Test_function func)
void set_parameters(const Parameters ¶ms)
static bool initialize(const std::string &rng_type, unsigned long seed)
void read(Field_G *U, const string &filename=string())
unsigned long get_unsigned_long(const string &key) const
double get_double(const string &key) const
void mult(Field &v, const Field &f)
multiplies fermion operator to a given field (2nd argument)
virtual void set_parameters(const Parameters &)=0
int non_NULL(const std::string v)
bool is_set(const string &key) const
Chebyshev polynomial of fermion operator.
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
void crucial(const char *format,...)
virtual void set_parameters(const Parameters ¶ms)=0
static void read(const std::string ¶ms_file, Parameters ¶ms)
Manager of smeared configurations.
int verify(const double result, const double expected, double eps)
void set_parameters(const Parameters ¶ms)
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
GaugeConfig class for file I/O of gauge configuration.
string get_string(const string &key) const
void report(const Bridge::VerboseLevel vl=Bridge::GENERAL)
static VerboseLevel set_verbose_level(const std::string &str)