Bridge++  Ver. 2.0.2
afopr.h
Go to the documentation of this file.
1 
14 #ifndef AFOPR_INCLUDED
15 #define AFOPR_INCLUDED
16 
17 #include <cstdio>
18 #include <cstdlib>
19 #include <string>
20 
22 #include "Parameters/parameters.h"
23 #include "Field/field.h"
24 #include "Field/field_G.h"
25 #include "IO/bridgeIO.h"
26 using Bridge::vout;
27 
28 #ifdef USE_FACTORY
29 #include "Tools/factory.h"
30 #include "Tools/director.h"
31 #endif
32 
33 class Field;
34 
47 template<typename AFIELD>
48 class AFopr
49 {
50  protected:
51  static const std::string class_name;
52 
53  public:
54  AFopr() {}
55  virtual ~AFopr() {}
56 
57  private:
59  AFopr(const AFopr&);
60  AFopr& operator=(const AFopr&);
61 
62  public:
63 
65  virtual void set_parameters(const Parameters& params)
66  {
67  vout.crucial("AFopr: set_parameters not implemented.\n");
68  }
69 
71  virtual void get_parameters(Parameters& params) const
72  {
73  vout.crucial("AFopr: get_parameters not implemented.\n");
74  }
75 
77  virtual void set_config(Field *) = 0;
78 
81  virtual void set_mode(std::string mode)
82  {
83  vout.crucial("Fopr: set_mode not implemented.\n");
84  exit(EXIT_FAILURE);
85  }
86 
88  virtual std::string get_mode() const
89  {
90  vout.general("Fopr: get_mode not implemented.\n");
91  return std::string();
92  }
93 
95  virtual void mult(AFIELD&, const AFIELD&)
96  {
97  vout.crucial("AFopr: mult not implemented.\n");
98  exit(EXIT_FAILURE);
99  }
100 
102  virtual void mult_dag(AFIELD&, const AFIELD&)
103  {
104  vout.crucial("AFopr: mult_dag not implemented.\n");
105  exit(EXIT_FAILURE);
106  }
107 
109  virtual void mult(AFIELD&, const AFIELD&, const std::string mode)
110  {
111  vout.crucial("AFopr: mult with mode not implemented.\n");
112  exit(EXIT_FAILURE);
113  }
114 
116  virtual void mult_dag(AFIELD&, const AFIELD&, const std::string mode)
117  {
118  vout.crucial("AFopr: mult with mode not implemented.\n");
119  exit(EXIT_FAILURE);
120  }
121 
123  virtual void mult_gm5(AFIELD&, const AFIELD&)
124  {
125  vout.crucial("AFopr: mult_gm5 not implemented.\n");
126  exit(EXIT_FAILURE);
127  }
128 
130  virtual void mult_up(int mu, AFIELD&, const AFIELD&)
131  {
132  vout.crucial("AFopr: mult_up not implemented.\n");
133  exit(EXIT_FAILURE);
134  }
135 
137  virtual void mult_dn(int mu, AFIELD&, const AFIELD&)
138  {
139  vout.crucial("AFopr: mult_dn not implemented.\n");
140  exit(EXIT_FAILURE);
141  }
142 
144  virtual void normalize_fprop(AFIELD&) { }
145 
147  virtual void normalize_fopr(AFIELD&) { }
148 
149 
151  virtual int field_nin() = 0;
152 
154  virtual int field_nvol() = 0;
155 
157  virtual int field_nex() = 0;
158 
160  virtual double flop_count()
161  {
162  vout.crucial("AFopr: flop_count is not implemented.\n");
163  return 0.0;
164  }
165 
167  virtual double flop_count(const std::string mode)
168  {
169  vout.crucial("AFopr: flop_count with mode is not implemented.\n");
170  return 0.0;
171  }
172 
174  virtual bool needs_convert() { return false; }
175 
177  virtual void convert(AFIELD&, const Field&)
178  {
179  vout.crucial("AFopr: convert is not implemented.\n");
180  exit(EXIT_FAILURE);
181  }
182 
184  virtual void reverse(Field&, const AFIELD&)
185  {
186  vout.crucial("AFopr: reverse is not implemented.\n");
187  exit(EXIT_FAILURE);
188  }
189 
190 #ifdef USE_FACTORY
191  public:
192  typedef AFopr *(*ProductCreator_noarg)();
193  typedef AFopr *(*ProductCreator_fopr)(AFopr *fopr);
194 
195  typedef AFopr *(*ProductCreator_fopr_director_params)(AFopr *fopr, Director *director, const Parameters& params);
196  typedef AFopr *(*ProductCreator_fopr_director)(AFopr *fopr, Director *director);
197  typedef AFopr *(*ProductCreator_string)(const std::string& arg);
198  typedef AFopr *(*ProductCreator_params)(const Parameters& params);
199  typedef AFopr *(*ProductCreator_fopr_params)(AFopr *fopr, const Parameters& params);
200 
201  typedef FactoryTemplate<AFopr, ProductCreator_noarg> Factory_noarg;
202  typedef FactoryTemplate<AFopr, ProductCreator_fopr> Factory_fopr;
204  Factory_fopr_director;
206  Factory_fopr_director_params;
207  typedef FactoryTemplate<AFopr, ProductCreator_string> Factory_string;
208  typedef FactoryTemplate<AFopr, ProductCreator_params> Factory_params;
210  Factory_fopr_params;
211 
212  static AFopr *New(const IdentifierType& subtype)
213  {
214  ProductCreator_noarg p = Factory_noarg::Find(subtype);
215  return p ? (*p)() : 0;
216  }
217 
218  static AFopr *New(const IdentifierType& subtype, AFopr *fopr)
219  {
220  ProductCreator_fopr p = Factory_fopr::Find(subtype);
221  return p ? (*p)(fopr) : 0;
222  }
223 
224  static AFopr *New(const IdentifierType& subtype, AFopr *fopr,
225  Director *director)
226  {
227  ProductCreator_fopr_director p = Factory_fopr_director::Find(subtype);
228  return p ? (*p)(fopr, director) : 0;
229  }
230 
231  static AFopr *New(const IdentifierType& subtype, AFopr *fopr,
232  Director *director, const Parameters& params)
233  {
234  ProductCreator_fopr_director_params p =
235  Factory_fopr_director_params::Find(subtype);
236  return p ? (*p)(fopr, director, params) : 0;
237  }
238 
239  static AFopr *New(const IdentifierType& subtype, const std::string& arg)
240  {
241  ProductCreator_string p = Factory_string::Find(subtype);
242  return p ? (*p)(arg) : 0;
243  }
244 
245  static AFopr *New(const IdentifierType& subtype, const Parameters& params)
246  {
247  ProductCreator_params p = Factory_params::Find(subtype);
248  return p ? (*p)(params) : 0;
249  }
250 
251  static AFopr *New(const IdentifierType& subtype,
252  AFopr *fopr, const Parameters& params)
253  {
254  ProductCreator_fopr_params p = Factory_fopr_params::Find(subtype);
255  return p ? (*p)(fopr, params) : 0;
256  }
257 
258 #ifdef USE_FACTORY_AUTOREGISTER
259 #else
260  static bool init_factory();
261 #endif
262 #endif // USE_FACTORY
263 };
264 
265 #endif // AFOPR_H
AFopr::normalize_fprop
virtual void normalize_fprop(AFIELD &)
normalize propagator if necessary (default: do nothing)
Definition: afopr.h:144
bridgeIO.h
field_G.h
AFopr::~AFopr
virtual ~AFopr()
Definition: afopr.h:55
AFopr::operator=
AFopr & operator=(const AFopr &)
AFopr
Definition: afopr.h:48
factory.h
AFopr::mult
virtual void mult(AFIELD &, const AFIELD &)
multiplies fermion operator to a given field.
Definition: afopr.h:95
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::field_nex
virtual int field_nex()=0
returns the external degree of freedom of the fermion field.
AFopr::convert
virtual void convert(AFIELD &, const Field &)
converts a Field object into other format if necessary.
Definition: afopr.h:177
AFopr::mult_dag
virtual void mult_dag(AFIELD &, const AFIELD &, const std::string mode)
executes mult_dag with specified mode (unchanging internal mode).
Definition: afopr.h:116
director.h
AFopr::set_mode
virtual void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: afopr.h:81
AFopr::mult_gm5
virtual void mult_gm5(AFIELD &, const AFIELD &)
multiplies gamma_5 matrix.
Definition: afopr.h:123
AFopr::normalize_fopr
virtual void normalize_fopr(AFIELD &)
normalize propagator if necessary (default: do nothing)
Definition: afopr.h:147
AFopr::set_config
virtual void set_config(Field *)=0
sets the gauge configuration.
AFopr::get_mode
virtual std::string get_mode() const
returns the current mult mode.
Definition: afopr.h:88
AFopr::mult_dag
virtual void mult_dag(AFIELD &, const AFIELD &)
hermitian conjugate of mult.
Definition: afopr.h:102
AFopr::class_name
static const std::string class_name
Definition: afopr.h:51
AFopr::needs_convert
virtual bool needs_convert()
returns true if additional field conversion is needed.
Definition: afopr.h:174
AFopr::mult
virtual void mult(AFIELD &, const AFIELD &, const std::string mode)
executes mult with specified mode (unchanging internal mode).
Definition: afopr.h:109
AFopr::field_nvol
virtual int field_nvol()=0
returns the volume of the fermion field.
AFopr::flop_count
virtual double flop_count()
returns the number of floating point operations.
Definition: afopr.h:160
field.h
parameters.h
FactoryTemplate
Definition: factory.h:42
AFopr::get_parameters
virtual void get_parameters(Parameters &params) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr.h:71
AFopr::mult_dn
virtual void mult_dn(int mu, AFIELD &, const AFIELD &)
downward nearest neighbor hopping term.
Definition: afopr.h:137
Director
Manager of commonly used data object in HMC.
Definition: director.h:37
commonParameters.h
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
AFopr::field_nin
virtual int field_nin()=0
returns the on-site degree of freedom of the fermion field.
AFopr::AFopr
AFopr()
Definition: afopr.h:54
AFopr::flop_count
virtual double flop_count(const std::string mode)
returns the flops per site for specified mode.
Definition: afopr.h:167
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
AFopr::set_parameters
virtual void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr.h:65
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
IdentifierType
std::string IdentifierType
Definition: factory.h:39
AFopr::mult_up
virtual void mult_up(int mu, AFIELD &, const AFIELD &)
upward nearest neighbor hopping term.
Definition: afopr.h:130