Bridge++  Ver. 2.0.2
afopr_Rational.h
Go to the documentation of this file.
1 
15 #ifndef AFOPR_RATIONAL_INCLUDED
16 #define AFOPR_RATIONAL_INCLUDED
17 
18 #include "Fopr/afopr.h"
19 
20 #include "Field/field_G.h"
21 #include "Solver/ashiftsolver_CG.h"
22 #include "Tools/math_Rational.h"
23 
24 #include "IO/bridgeIO.h"
25 using Bridge::vout;
26 
28 
41 template<typename AFIELD>
42 class AFopr_Rational : public AFopr<AFIELD>
43 {
44  public:
45  typedef typename AFIELD::real_t real_t;
46  static const std::string class_name;
47 
48  private:
50 
51  int m_Np; // number of poles in rational approx.
52  int m_n_exp, m_d_exp; // numerator and denominator of the exponent
53  real_t m_x_min, m_x_max; // valid range of approximate sign function
54  int m_Niter; // max iteration of shiftsolver
55  real_t m_Stop_cond; // stopping condition of shift solver
56 
59 
61  std::vector<real_t> m_cl;
62  std::vector<real_t> m_bl;
63  std::vector<AFIELD> m_xq;
64 
65  public:
67  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr) {}
68 
69  AFopr_Rational(AFopr<AFIELD> *fopr, const Parameters& params)
70  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr)
71  {
72  set_parameters(params);
73  }
74 
76  {
77  delete m_solver;
78  }
79 
80  void set_parameters(const Parameters& params);
81  void set_parameters(const int Np, const int n_exp, const int d_exp,
82  const real_t x_min, const real_t x_max,
83  const int Niter, const real_t Stop_cond);
84 
85  void get_parameters(Parameters& params) const;
86 
87  void set_config(Field *U);
88 
89  void mult(AFIELD& v, const AFIELD& f);
90 
91  void mult_dag(AFIELD& v, const AFIELD& f)
92  {
93  mult(v, f);
94  }
95 
96  real_t func(const real_t x);
97 
98  int field_nvol() { return m_fopr->field_nvol(); }
99  int field_nin() { return m_fopr->field_nin(); }
100  int field_nex() { return m_fopr->field_nex(); }
101 
103  virtual bool needs_convert()
104  { return m_fopr->needs_convert(); }
105 
107  virtual void convert(AFIELD& v, const Field& w)
108  { m_fopr->convert(v, w); }
109 
111  virtual void reverse(Field& v, const AFIELD& w)
112  { m_fopr->reverse(v, w); }
113 
114  private:
115  void init_parameters();
116 
117 #ifdef USE_FACTORY
118  private:
119  static AFopr<AFIELD> *create_object(AFopr<AFIELD> *fopr)
120  { return new AFopr_Rational<AFIELD>(fopr); }
121 
122  static AFopr<AFIELD> *create_object_with_params(AFopr<AFIELD> *fopr, const Parameters& params)
123  { return new AFopr_Rational<AFIELD>(fopr, params); }
124 
125  public:
126  static bool register_factory()
127  {
128  bool init = true;
129  init &= AFopr<AFIELD>::Factory_fopr::Register("Rational", create_object);
130  init &= AFopr<AFIELD>::Factory_fopr_params::Register("Rational", create_object_with_params);
131  return init;
132  }
133 #endif
134 };
135 #endif
AFopr_Rational::field_nin
int field_nin()
returns the on-site degree of freedom of the fermion field.
Definition: afopr_Rational.h:99
bridgeIO.h
field_G.h
AFopr_Rational::m_d_exp
int m_d_exp
Definition: afopr_Rational.h:52
AFopr_Rational::m_a0
real_t m_a0
Definition: afopr_Rational.h:60
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
AFopr
Definition: afopr.h:48
AFopr_Rational::m_vl
Bridge::VerboseLevel m_vl
Definition: afopr_Rational.h:49
Parameters
Class for parameters.
Definition: parameters.h:46
AFopr_Rational::mult
void mult(AFIELD &v, const AFIELD &f)
multiplies fermion operator to a given field.
Definition: afopr_Rational-tmpl.h:180
AFopr_Rational::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr_Rational-tmpl.h:31
AFopr_Rational::needs_convert
virtual bool needs_convert()
returns true if additional field conversion is needed.
Definition: afopr_Rational.h:103
AFopr_Rational::func
real_t func(const real_t x)
Definition: afopr_Rational-tmpl.h:214
AFopr_Rational::convert
virtual void convert(AFIELD &v, const Field &w)
converts a Field object into other format if necessary.
Definition: afopr_Rational.h:107
AFopr_Rational::AFopr_Rational
AFopr_Rational(AFopr< AFIELD > *fopr, const Parameters &params)
Definition: afopr_Rational.h:69
AFopr_Rational::m_x_max
real_t m_x_max
Definition: afopr_Rational.h:53
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AFopr_Rational::m_bl
std::vector< real_t > m_bl
Definition: afopr_Rational.h:62
Field::real_t
double real_t
Definition: field.h:51
AFopr_Rational::m_solver
AShiftsolver_CG< AFIELD, AFopr< AFIELD > > * m_solver
Definition: afopr_Rational.h:58
AFopr_Rational::~AFopr_Rational
~AFopr_Rational()
Definition: afopr_Rational.h:75
math_Rational.h
AFopr_Rational::m_xq
std::vector< AFIELD > m_xq
Definition: afopr_Rational.h:63
AFopr_Rational::m_Stop_cond
real_t m_Stop_cond
Definition: afopr_Rational.h:55
AFopr_Rational::class_name
static const std::string class_name
Definition: afopr_Rational.h:46
AFopr_Rational::get_parameters
void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr_Rational-tmpl.h:66
AFopr_Rational::m_Niter
int m_Niter
Definition: afopr_Rational.h:54
AFopr_Rational::m_Np
int m_Np
Definition: afopr_Rational.h:51
AFopr_Rational::m_x_min
real_t m_x_min
Definition: afopr_Rational.h:53
AFopr_Rational
Fermion operator for rational approximation.
Definition: afopr_Rational.h:42
AFopr_Rational::real_t
AFIELD::real_t real_t
Definition: afopr_Rational.h:45
ashiftsolver_CG.h
AFopr_Rational::m_n_exp
int m_n_exp
Definition: afopr_Rational.h:52
AFopr_Rational::reverse
virtual void reverse(Field &v, const AFIELD &w)
reverses to a Field object from other format if necessary.
Definition: afopr_Rational.h:111
AFopr_Rational::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: afopr_Rational-tmpl.h:129
AFopr_Rational::AFopr_Rational
AFopr_Rational(AFopr< AFIELD > *fopr)
Definition: afopr_Rational.h:66
Field
Container of Field-type object.
Definition: field.h:46
afopr.h
AFopr_Rational::field_nex
int field_nex()
returns the external degree of freedom of the fermion field.
Definition: afopr_Rational.h:100
AShiftsolver_CG
Multishift Conjugate Gradient solver.
Definition: ashiftsolver_CG.h:32
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
AFopr_Rational::field_nvol
int field_nvol()
returns the volume of the fermion field.
Definition: afopr_Rational.h:98
AFopr_Rational::m_fopr
AFopr< AFIELD > * m_fopr
Definition: afopr_Rational.h:57
AFopr_Rational::init_parameters
void init_parameters()
Definition: afopr_Rational-tmpl.h:136
AFopr_Rational::m_cl
std::vector< real_t > m_cl
Definition: afopr_Rational.h:61
AFopr_Rational::mult_dag
void mult_dag(AFIELD &v, const AFIELD &f)
hermitian conjugate of mult.
Definition: afopr_Rational.h:91
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512