Go to the documentation of this file.
17 #ifdef USE_FACTORY_AUTOREGISTER
23 template<
typename AFIELD>
27 template<
typename AFIELD>
34 vout.
general(m_vl,
"%s: construction\n", class_name.c_str());
35 vout.
general(m_vl,
" -- Sign function with Zolotarev approximation\n");
38 m_Nin = m_fopr->field_nin();
39 m_Nvol = m_fopr->field_nvol();
40 m_Nex = m_fopr->field_nex();
48 set_parameters(params);
57 template<
typename AFIELD>
64 vout.
general(m_vl,
"%s: construction (obsolete)\n", class_name.c_str());
65 vout.
general(m_vl,
" -- Sign function with Zolotarev approximation\n");
67 m_Nin = m_fopr->field_nin();
68 m_Nvol = m_fopr->field_nvol();
69 m_Nex = m_fopr->field_nex();
81 template<
typename AFIELD>
89 template<
typename AFIELD>
108 err += params.
fetch_int(
"number_of_poles", Np);
111 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
112 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
115 vout.
crucial(m_vl,
"Error at %s: input parameter not found.\n",
121 Niter,
real_t(Stop_cond));
126 template<
typename AFIELD>
144 vout.
crucial(m_vl,
"Error at %s: parameter range check failed.\n",
156 m_Stop_cond = Stop_cond;
158 m_sigma.resize(m_Np);
159 m_cl.resize(2 * m_Np);
165 vout.
general(m_vl,
"%s: parameters\n", class_name.c_str());
170 vout.
general(m_vl,
" Stop_cond = %8.2e\n", m_Stop_cond);
179 template<
typename AFIELD>
188 m_sigma.resize(m_Np);
189 m_cl.resize(2 * m_Np);
193 const real_t bmax = m_x_max / m_x_min;
198 for (
int i = 0; i < m_Np; i++) {
199 m_sigma[i] = m_cl[2 * i] * m_x_min * m_x_min;
202 for (
int i = 0; i < m_Np; i++) {
204 i, m_cl[i], m_cl[i + m_Np], m_bl[i]);
208 for (
int i = 0; i < m_Np; ++i) {
209 m_xq[i].reset(m_Nin, m_Nvol, m_Nex);
213 params_solver.
set_int(
"number_of_shifts", m_Np);
214 params_solver.
set_int(
"maximum_number_of_iteration", m_Niter);
215 params_solver.
set_double(
"convergence_criterion_squared", m_Stop_cond);
219 m_fopr, params_solver);
224 m_w1.reset(m_Nin, m_Nvol, m_Nex);
234 template<
typename AFIELD>
237 params.
set_int(
"number_of_poles", m_Np);
238 params.
set_double(
"lower_bound",
double(m_x_min));
239 params.
set_double(
"upper_bound",
double(m_x_max));
240 params.
set_int(
"maximum_number_of_iteration", m_Niter);
241 params.
set_double(
"convergence_criterion_squared",
double(m_Stop_cond));
248 template<
typename AFIELD>
251 m_fopr->set_config(U);
256 template<
typename AFIELD>
262 if (ith == 0) m_mode = mode;
264 m_fopr->set_mode(mode);
272 template<
typename AFIELD>
274 std::vector<real_t> *ev,
275 std::vector<AFIELD> *vk)
277 if ((Nsbt > ev->size()) || (Nsbt > vk->size())) {
278 vout.
crucial(m_vl,
"Error at %s: Nsbt is larger than array size\n",
290 template<
typename AFIELD>
299 if (m_Nsbt > 0) subtract_lowmodes(m_w1);
301 m_fopr->set_mode(
"DdagD");
305 m_solver->solve(m_xq, m_sigma, m_w1, Nconv, diff);
310 for (
int i = 0; i < m_Np; i++) {
311 axpy(v, m_bl[i], m_xq[i]);
315 m_fopr->mult(m_w1, v);
317 const real_t coeff = m_cl[2 * m_Np - 1] * m_x_min * m_x_min;
318 axpy(m_w1, coeff, v);
320 m_fopr->set_mode(
"H");
321 m_fopr->mult(v, m_w1);
323 scal(v, 1.0 / m_x_min);
326 if (m_Nsbt > 0) evaluate_lowmodes(v, b);
331 template<
typename AFIELD>
336 for (
int k = 0; k < m_Nsbt; ++k) {
338 axpy(w, -prod, (*m_vk)[k]);
345 template<
typename AFIELD>
350 for (
int k = 0; k < m_Nsbt; ++k) {
354 real_t sgn = ev / fabs(ev);
356 axpy(x, prod, (*m_vk)[k]);
363 template<
typename AFIELD>
370 for (
int l = 0; l < m_Np; l++) {
371 x2R += m_bl[l] / (x * x + m_cl[2 * l]);
373 x2R = x2R * (x * x + m_cl[2 * m_Np - 1]);
380 template<
typename AFIELD>
388 template<
typename AFIELD>
393 double gflop_solver = m_solver->flop_count();
395 double gflop_fopr = m_fopr->flop_count(
"DdagD")
396 + m_fopr->flop_count(
"H");
398 double flop_blas = m_Nin * m_Nex * ((m_Np + 1) * 2 + 1);
401 int flop_subt = m_Nsbt * m_Nin * m_Nex * 4 * 2 * 2;
406 double flop_site = double(flop_blas) + double(flop_subt);
408 double gflop = flop_site * double(m_Nvol) * double(NPE) * 1.0e-9;
410 gflop += gflop_solver + gflop_fopr;
void set_lowmodes(const int Nsbt, std::vector< real_t > *, std::vector< AFIELD > *)
void get_parameters(Parameters ¶ms) const
gets parameters by a Parameter object: to be implemented in a subclass.
void set_string(const string &key, const string &value)
void set_config(Field *U)
sets the gauge configuration.
Sign function of a given fermion operator.
void set(const int jin, const int site, const int jex, double v)
void set_parameters(const Parameters ¶ms)
sets parameters by a Parameter object: to be implemented in a subclass.
void get_sign_parameters(std::vector< double > &cl, std::vector< double > &bl)
void set_double(const string &key, const double value)
bool check_size(const int nin, const int nvol, const int nex) const
checking size parameters. [23 May 2016 H.Matsufuru]
ComplexTraits< real_t >::complex_t complex_t
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
real_t sign_zolotarev(const real_t x)
void copy(Field &y, const Field &x)
copy(y, x): y = x
int square_non_zero(const double v)
void evaluate_lowmodes(AFIELD &, const AFIELD &)
dcomplex dotc(const Field &y, const Field &x)
void subtract_lowmodes(AFIELD &)
static Bridge::VerboseLevel Vlevel()
static VerboseLevel set_verbose_level(const std::string &str)
int non_zero(const double v)
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)
void scal(Field &x, const double a)
scal(x, a): x = a * x
int fetch_string(const string &key, string &value) const
int fetch_double(const string &key, double &value) const
void crucial(const char *format,...)
void mult(AFIELD &v, const AFIELD &w)
multiplies fermion operator to a given field.
Container of Field-type object.
static int get_thread_id()
returns thread id.
Multishift Conjugate Gradient solver.
int fetch_int(const string &key, int &value) const
void general(const char *format,...)
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
double flop_count()
returns the number of floating point operations.
static std::string get_verbose_level(const VerboseLevel vl)
Determination of Zolotarev coefficients.