Bridge++  Ver. 2.0.2
afopr_Sign.h
Go to the documentation of this file.
1 
14 #ifndef AFOPR_SIGN_INCLUDED
15 #define AFOPR_SIGN_INCLUDED
16 
17 #include "Fopr/afopr.h"
18 
19 #include "Field/field_G.h"
20 #include "Solver/ashiftsolver_CG.h"
22 #include "bridge_complex.h"
23 #include "complexTraits.h"
24 
25 #include "IO/bridgeIO.h"
26 using Bridge::vout;
27 
29 
55 template<typename AFIELD>
56 class AFopr_Sign : public AFopr<AFIELD>
57 {
58  public:
60  typedef typename AFIELD::real_t real_t;
62 
63  static const std::string class_name;
64 
65  private:
66  // input parameters
67  int m_Np;
70  int m_Niter;
72 
74 
75  std::string m_mode;
76 
78 
79  // local parameters
81 
82  std::vector<real_t> m_cl;
83  std::vector<real_t> m_bl;
84  std::vector<real_t> m_sigma;
85 
86  //- low-mode subtraction
87  int m_Nsbt;
88  std::vector<real_t> *m_ev;
89  std::vector<AFIELD> *m_vk;
90 
91  //- shiftsolver
93  std::vector<AFIELD> m_xq;
94 
95  //- workarea
97 
98  public:
99 
100  AFopr_Sign(AFOPR *fopr, const Parameters& params) : m_fopr(fopr)
101  { init(params); }
102 
103  DEPRECATED
104  AFopr_Sign(AFOPR *fopr) : m_fopr(fopr) { init(); }
105 
107 
108  void set_parameters(const Parameters& params);
109 
110  void set_parameters(const int Np, const real_t x_min, const real_t x_max,
111  const int Niter, const real_t Stop_cond);
112 
113  void get_parameters(Parameters& params) const;
114 
115  void set_config(Field *U);
116 
117  void set_mode(const std::string mode);
118 
119  std::string get_mode() const { return m_mode; }
120 
121  void set_lowmodes(const int Nsbt, std::vector<real_t> *,
122  std::vector<AFIELD> *);
123 
124  void mult(AFIELD& v, const AFIELD& w);
125 
126  void mult_dag(AFIELD& v, const AFIELD& w) { mult(v, w); }
127 
129  virtual bool needs_convert()
130  { return m_fopr->needs_convert(); }
131 
133  virtual void convert(AFIELD& v, const Field& w)
134  { m_fopr->convert(v, w); }
135 
137  virtual void reverse(Field& v, const AFIELD& w)
138  { m_fopr->reverse(v, w); }
139 
140  int field_nin() { return m_Nin; }
141  int field_nvol() { return m_Nvol; }
142  int field_nex() { return m_Nex; }
143 
145  double flop_count();
146 
148  double flop_count(const std::string mode);
149 
150  private:
151  void init();
152 
153  void init(const Parameters& params);
154 
155  void tidyup();
156 
157  void init_parameters();
158 
159  void subtract_lowmodes(AFIELD&);
160  void evaluate_lowmodes(AFIELD&, const AFIELD&);
161 
162  real_t sign_zolotarev(const real_t x);
163 
164 #ifdef USE_FACTORY
165  private:
166  static AFOPR *create_object(AFOPR *fopr)
167  {
168  return new AFopr_Sign<AFIELD>(fopr);
169  }
170 
171  static AFOPR *create_object_with_params(AFOPR *fopr, const Parameters& params)
172  {
173  return new AFopr_Sign<AFIELD>(fopr, params);
174  }
175 
176  public:
177  static bool register_factory()
178  {
179  bool init = true;
180  init &= AFOPR::Factory_fopr::Register("Sign", create_object);
181  init &= AFOPR::Factory_fopr_params::Register("Sign", create_object_with_params);
182  return init;
183  }
184 #endif
185 };
186 #endif
AFopr_Sign::set_lowmodes
void set_lowmodes(const int Nsbt, std::vector< real_t > *, std::vector< AFIELD > *)
Definition: afopr_Sign-tmpl.h:260
AFopr_Sign::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr_Sign-tmpl.h:222
bridgeIO.h
field_G.h
AFopr_Sign::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: afopr_Sign-tmpl.h:236
AFopr
Definition: afopr.h:48
AFopr_Sign::field_nin
int field_nin()
returns the on-site degree of freedom of the fermion field.
Definition: afopr_Sign.h:140
AFopr_Sign
Sign function of a given fermion operator.
Definition: afopr_Sign.h:56
AFopr_Sign::m_x_max
real_t m_x_max
upper range of approximate sign function
Definition: afopr_Sign.h:69
AFopr_Sign::field_nvol
int field_nvol()
returns the volume of the fermion field.
Definition: afopr_Sign.h:141
Parameters
Class for parameters.
Definition: parameters.h:46
AFopr::reverse
virtual void reverse(Field &, const AFIELD &)
converts an alternative field to a Field object.
Definition: afopr.h:184
AFopr_Sign::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr_Sign-tmpl.h:88
AFopr_Sign::AFopr_Sign
DEPRECATED AFopr_Sign(AFOPR *fopr)
Definition: afopr_Sign.h:104
AFopr_Sign::needs_convert
virtual bool needs_convert()
returns true if additional field conversion is needed.
Definition: afopr_Sign.h:129
AFopr_Sign::m_cl
std::vector< real_t > m_cl
Definition: afopr_Sign.h:82
AFopr_Sign::AFopr_Sign
AFopr_Sign(AFOPR *fopr, const Parameters &params)
Definition: afopr_Sign.h:100
AFopr_Sign::m_mode
std::string m_mode
Definition: afopr_Sign.h:75
AFopr::convert
virtual void convert(AFIELD &, const Field &)
converts a Field object into other format if necessary.
Definition: afopr.h:177
AFopr_Sign::complex_t
ComplexTraits< real_t >::complex_t complex_t
Definition: afopr_Sign.h:61
AFopr_Sign::m_x_min
real_t m_x_min
lower range of approximate sign function
Definition: afopr_Sign.h:68
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AFopr_Sign::m_fopr
AFOPR * m_fopr
Definition: afopr_Sign.h:77
AFopr_Sign::get_mode
std::string get_mode() const
returns the current mult mode.
Definition: afopr_Sign.h:119
AFopr_Sign::m_Np
int m_Np
number of poles in rational approx.
Definition: afopr_Sign.h:67
AFopr_Sign::sign_zolotarev
real_t sign_zolotarev(const real_t x)
Definition: afopr_Sign-tmpl.h:351
AFopr_Sign::m_Nex
int m_Nex
Definition: afopr_Sign.h:80
Field::real_t
double real_t
Definition: field.h:51
math_Sign_Zolotarev.h
AFopr_Sign::m_bl
std::vector< real_t > m_bl
Definition: afopr_Sign.h:83
AFopr_Sign::m_vk
std::vector< AFIELD > * m_vk
Definition: afopr_Sign.h:89
AFopr::needs_convert
virtual bool needs_convert()
returns true if additional field conversion is needed.
Definition: afopr.h:174
bridge_complex.h
AFopr_Sign::m_ev
std::vector< real_t > * m_ev
Definition: afopr_Sign.h:88
AFopr_Sign::AFOPR
AFopr< AFIELD > AFOPR
Definition: afopr_Sign.h:59
AFopr_Sign::m_solver
AShiftsolver_CG< AFIELD, AFOPR > * m_solver
Definition: afopr_Sign.h:92
AFopr_Sign::m_vl
Bridge::VerboseLevel m_vl
Definition: afopr_Sign.h:73
AFopr_Sign::evaluate_lowmodes
void evaluate_lowmodes(AFIELD &, const AFIELD &)
Definition: afopr_Sign-tmpl.h:333
AFopr_Sign::field_nex
int field_nex()
returns the external degree of freedom of the fermion field.
Definition: afopr_Sign.h:142
AFopr_Sign::m_sigma
std::vector< real_t > m_sigma
Definition: afopr_Sign.h:84
AFopr_Sign::~AFopr_Sign
~AFopr_Sign()
Definition: afopr_Sign.h:106
AFopr_Sign::m_w1
AFIELD m_w1
Definition: afopr_Sign.h:96
AFopr_Sign::m_Nin
int m_Nin
Definition: afopr_Sign.h:80
AFopr_Sign::m_Nvol
int m_Nvol
Definition: afopr_Sign.h:80
AFopr_Sign::class_name
static const std::string class_name
Definition: afopr_Sign.h:63
ComplexTraits
Definition: complexTraits.h:16
AFopr_Sign::m_Stop_cond
real_t m_Stop_cond
stopping condition of shift solver
Definition: afopr_Sign.h:71
AFopr_Sign::m_xq
std::vector< AFIELD > m_xq
Definition: afopr_Sign.h:93
ashiftsolver_CG.h
AFopr_Sign::convert
virtual void convert(AFIELD &v, const Field &w)
converts a Field object into other format if necessary.
Definition: afopr_Sign.h:133
AFopr_Sign::real_t
AFIELD::real_t real_t
Definition: afopr_Sign.h:60
AFopr_Sign::subtract_lowmodes
void subtract_lowmodes(AFIELD &)
Definition: afopr_Sign-tmpl.h:319
AFopr_Sign::reverse
virtual void reverse(Field &v, const AFIELD &w)
reverses to a Field object from other format if necessary.
Definition: afopr_Sign.h:137
AFopr_Sign::m_Niter
int m_Niter
max iteration of shiftsolver
Definition: afopr_Sign.h:70
AFopr_Sign::set_mode
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: afopr_Sign-tmpl.h:244
AFopr_Sign::mult_dag
void mult_dag(AFIELD &v, const AFIELD &w)
hermitian conjugate of mult.
Definition: afopr_Sign.h:126
AFopr_Sign::init
void init()
Definition: afopr_Sign-tmpl.h:56
AFopr_Sign::mult
void mult(AFIELD &v, const AFIELD &w)
multiplies fermion operator to a given field.
Definition: afopr_Sign-tmpl.h:278
complexTraits.h
Field
Container of Field-type object.
Definition: field.h:46
afopr.h
AShiftsolver_CG
Multishift Conjugate Gradient solver.
Definition: ashiftsolver_CG.h:32
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
AFopr_Sign::m_Nsbt
int m_Nsbt
Definition: afopr_Sign.h:87
AFopr_Sign::init_parameters
void init_parameters()
Definition: afopr_Sign-tmpl.h:174
DEPRECATED
#define DEPRECATED
Definition: configure.h:28
AFopr_Sign::flop_count
double flop_count()
returns the number of floating point operations.
Definition: afopr_Sign-tmpl.h:368
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AFopr_Sign::tidyup
void tidyup()
Definition: afopr_Sign-tmpl.h:80