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();
46 set_parameters(params);
55 template<
typename AFIELD>
62 vout.
general(m_vl,
"%s: construction (obsolete)\n", class_name.c_str());
63 vout.
general(m_vl,
" -- Sign function with Zolotarev approximation\n");
65 m_Nin = m_fopr->field_nin();
66 m_Nvol = m_fopr->field_nvol();
67 m_Nex = m_fopr->field_nex();
79 template<
typename AFIELD>
87 template<
typename AFIELD>
106 err += params.
fetch_int(
"number_of_poles", Np);
109 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
110 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
113 vout.
crucial(m_vl,
"Error at %s: input parameter not found.\n",
119 Niter,
real_t(Stop_cond));
124 template<
typename AFIELD>
142 vout.
crucial(m_vl,
"Error at %s: parameter range check failed.\n",
152 m_Stop_cond = Stop_cond;
154 m_sigma.resize(m_Np);
155 m_cl.resize(2 * m_Np);
161 vout.
general(m_vl,
"%s: input parameters\n", class_name.c_str());
166 vout.
general(m_vl,
" Stop_cond = %8.2e\n", m_Stop_cond);
173 template<
typename AFIELD>
182 m_sigma.resize(m_Np);
183 m_cl.resize(2 * m_Np);
187 const real_t bmax = m_x_max / m_x_min;
192 for (
int i = 0; i < m_Np; i++) {
193 m_sigma[i] = m_cl[2 * i] * m_x_min * m_x_min;
196 for (
int i = 0; i < m_Np; i++) {
198 i, m_cl[i], m_cl[i + m_Np], m_bl[i]);
202 for (
int i = 0; i < m_Np; ++i) {
203 m_xq[i].reset(m_Nin, m_Nvol, m_Nex);
211 m_w1.reset(m_Nin, m_Nvol, m_Nex);
221 template<
typename AFIELD>
224 params.
set_int(
"number_of_poles", m_Np);
225 params.
set_double(
"lower_bound",
double(m_x_min));
226 params.
set_double(
"upper_bound",
double(m_x_max));
227 params.
set_int(
"maximum_number_of_iteration", m_Niter);
228 params.
set_double(
"convergence_criterion_squared",
double(m_Stop_cond));
235 template<
typename AFIELD>
238 m_fopr->set_config(U);
243 template<
typename AFIELD>
249 if (ith == 0) m_mode = mode;
251 m_fopr->set_mode(mode);
259 template<
typename AFIELD>
261 std::vector<real_t> *ev,
262 std::vector<AFIELD> *vk)
264 if ((Nsbt > ev->size()) || (Nsbt > vk->size())) {
265 vout.
crucial(m_vl,
"Error at %s: Nsbt is larger than array size\n",
277 template<
typename AFIELD>
286 if (m_Nsbt > 0) subtract_lowmodes(m_w1);
288 m_fopr->set_mode(
"DdagD");
292 m_solver->solve(m_xq, m_sigma, m_w1, Nconv, diff);
297 for (
int i = 0; i < m_Np; i++) {
298 axpy(v, m_bl[i], m_xq[i]);
302 m_fopr->mult(m_w1, v);
304 const real_t coeff = m_cl[2 * m_Np - 1] * m_x_min * m_x_min;
305 axpy(m_w1, coeff, v);
307 m_fopr->set_mode(
"H");
308 m_fopr->mult(v, m_w1);
310 scal(v, 1.0 / m_x_min);
313 if (m_Nsbt > 0) evaluate_lowmodes(v, b);
318 template<
typename AFIELD>
323 for (
int k = 0; k < m_Nsbt; ++k) {
325 axpy(w, -prod, (*m_vk)[k]);
332 template<
typename AFIELD>
337 for (
int k = 0; k < m_Nsbt; ++k) {
341 real_t sgn = ev / fabs(ev);
343 axpy(x, prod, (*m_vk)[k]);
350 template<
typename AFIELD>
357 for (
int l = 0; l < m_Np; l++) {
358 x2R += m_bl[l] / (x * x + m_cl[2 * l]);
360 x2R = x2R * (x * x + m_cl[2 * m_Np - 1]);
367 template<
typename AFIELD>
375 template<
typename AFIELD>
380 double gflop_solver = m_solver->flop_count();
382 double gflop_fopr = m_fopr->flop_count(
"DdagD")
383 + m_fopr->flop_count(
"H");
385 double flop_blas = m_Nin * m_Nex * ((m_Np + 1) * 2 + 1);
388 int flop_subt = m_Nsbt * m_Nin * m_Nex * 4 * 2 * 2;
393 double flop_site = double(flop_blas) + double(flop_subt);
395 double gflop = flop_site * double(m_Nvol) * double(NPE) * 1.0e-9;
397 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.