Bridge++  Ver. 2.0.2
fopr_CRS.h
Go to the documentation of this file.
1 
15 #ifndef FOPR_CRS_INCLUDED
16 #define FOPR_CRS_INCLUDED
17 
18 #include <string>
19 
20 #include "fopr.h"
21 
22 #include "IO/bridgeIO.h"
23 using Bridge::vout;
24 
26 
37 class Fopr_CRS : public Fopr
38 {
39  public:
40  static const std::string class_name;
41 
42  private:
44 
46  int m_Nsize, m_Nnz;
47  std::vector<int> m_rowidx_nz;
48  std::vector<int> m_column_nz;
49  std::vector<double> m_elem_nz;
50  std::string m_mode;
52 
53  public:
54 
55  Fopr_CRS(Fopr *fopr)
56  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr)
57  {
58  set_matrix();
59  }
60 
61  Fopr_CRS(const std::string fname)
62  : m_vl(CommonParameters::Vlevel()), m_fopr(0)
63  {
64  set_matrix(fname);
65  }
66 
67  void set_parameters(const Parameters&);
68 
69  void get_parameters(Parameters&) const;
70 
71  void write_matrix(const std::string);
72 
73  void set_config(Field *U)
74  {
75  if (m_fopr == 0) {
76  vout.crucial(m_vl, "Error at %s: fopr is not set.\n", class_name.c_str());
77  exit(EXIT_FAILURE);
78  } else {
79  m_fopr->set_config(U);
80  }
81  }
82 
83  void set_mode(const std::string mode);
84 
85  std::string get_mode() const
86  {
87  return m_mode;
88  }
89 
90  void mult(Field& v, const Field& f)
91  {
92  if (m_mode == "D") {
93  D(v, f);
94  } else if (m_mode == "DdagD") {
95  DdagD(v, f);
96  } else if (m_mode == "Ddag") {
97  Ddag(v, f);
98  } else {
99  vout.crucial(m_vl, "Error at %s: mode unknown: '%s'.\n", class_name.c_str(), m_mode.c_str());
100  exit(EXIT_FAILURE);
101  }
102  }
103 
104  void mult_dag(Field& v, const Field& f)
105  {
106  if (m_mode == "D") {
107  Ddag(v, f);
108  } else if (m_mode == "DdagD") {
109  DdagD(v, f);
110  } else if (m_mode == "Ddag") {
111  D(v, f);
112  } else {
113  vout.crucial(m_vl, "Error at %s: mode unknown: '%s'.\n", class_name.c_str(), m_mode.c_str());
114  exit(EXIT_FAILURE);
115  }
116  }
117 
118  void DdagD(Field&, const Field&);
119  void D(Field&, const Field&);
120  void Ddag(Field&, const Field&);
121  void H(Field&, const Field&);
122 
123  int field_nvol() { return m_Nvol; }
124  int field_nin() { return m_Nin; }
125  int field_nex() { return m_Nex; }
126 
128  double flop_count();
129 
130  private:
131  void set_matrix();
132  void set_matrix(const std::string);
133 
134  void set_matrix_1row(int&, std::vector<int>&,
135  std::vector<double>&, const Field&);
136 
137 #ifdef USE_FACTORY
138  private:
139  static Fopr *create_object_with_fopr(Fopr *fopr)
140  {
141  return new Fopr_CRS(fopr);
142  }
143 
144  static Fopr *create_object_with_filename(const std::string& fname)
145  {
146  return new Fopr_CRS(fname);
147  }
148 
149  public:
150  static bool register_factory()
151  {
152  bool init1 = Fopr::Factory_fopr::Register("CRS", create_object_with_fopr);
153  bool init2 = Fopr::Factory_string::Register("CRS", create_object_with_filename);
154 
155  return init1 && init2;
156  }
157 #endif
158 };
159 #endif
Fopr_CRS::set_config
void set_config(Field *U)
sets the gauge configuration.
Definition: fopr_CRS.h:73
bridgeIO.h
Fopr_CRS::m_Nnz
int m_Nnz
Definition: fopr_CRS.h:46
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
AFopr
Definition: afopr.h:48
Fopr_CRS::Fopr_CRS
Fopr_CRS(Fopr *fopr)
Definition: fopr_CRS.h:55
Parameters
Class for parameters.
Definition: parameters.h:46
Fopr_CRS::mult_dag
void mult_dag(Field &v, const Field &f)
hermitian conjugate of mult.
Definition: fopr_CRS.h:104
Fopr_CRS::set_matrix
void set_matrix()
Definition: fopr_CRS.cpp:140
Fopr_CRS::m_mode
std::string m_mode
Definition: fopr_CRS.h:50
Fopr_CRS::Fopr_CRS
Fopr_CRS(const std::string fname)
Definition: fopr_CRS.h:61
Fopr_CRS::D
void D(Field &, const Field &)
Definition: fopr_CRS.cpp:68
Fopr_CRS::get_parameters
void get_parameters(Parameters &) const
gets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_CRS.cpp:39
Fopr_CRS::field_nin
int field_nin()
returns the on-site degree of freedom of the fermion field.
Definition: fopr_CRS.h:124
Fopr_CRS::field_nvol
int field_nvol()
returns the volume of the fermion field.
Definition: fopr_CRS.h:123
AFopr::set_config
virtual void set_config(Field *)=0
sets the gauge configuration.
Fopr_CRS::class_name
static const std::string class_name
Definition: fopr_CRS.h:40
Fopr_CRS::m_column_nz
std::vector< int > m_column_nz
Definition: fopr_CRS.h:48
Fopr_CRS::m_vl
Bridge::VerboseLevel m_vl
Definition: fopr_CRS.h:43
Fopr_CRS::get_mode
std::string get_mode() const
Definition: fopr_CRS.h:85
Fopr_CRS::flop_count
double flop_count()
this returns the number of floating point operations.
Definition: fopr_CRS.cpp:335
Fopr_CRS::Ddag
void Ddag(Field &, const Field &)
Definition: fopr_CRS.cpp:105
Fopr_CRS::m_Nvol
int m_Nvol
Definition: fopr_CRS.h:45
Fopr_CRS::m_elem_nz
std::vector< double > m_elem_nz
Definition: fopr_CRS.h:49
Fopr_CRS::set_matrix_1row
void set_matrix_1row(int &, std::vector< int > &, std::vector< double > &, const Field &)
Definition: fopr_CRS.cpp:223
Fopr_CRS::set_parameters
void set_parameters(const Parameters &)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: fopr_CRS.cpp:29
Fopr_CRS::m_Nsize
int m_Nsize
Definition: fopr_CRS.h:46
Fopr_CRS::field_nex
int field_nex()
returns the external degree of freedom of the fermion field.
Definition: fopr_CRS.h:125
Fopr_CRS::mult
void mult(Field &v, const Field &f)
multiplies fermion operator to a given field.
Definition: fopr_CRS.h:90
Fopr_CRS::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: fopr_CRS.cpp:46
fopr.h
Fopr_CRS::m_fopr
Fopr * m_fopr
Definition: fopr_CRS.h:51
Fopr_CRS::H
void H(Field &, const Field &)
Fopr_CRS::m_Nex
int m_Nex
Definition: fopr_CRS.h:45
Fopr_CRS::write_matrix
void write_matrix(const std::string)
Definition: fopr_CRS.cpp:293
Fopr_CRS
Fermion operator with CRS matrix format.
Definition: fopr_CRS.h:37
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Fopr_CRS::m_rowidx_nz
std::vector< int > m_rowidx_nz
Definition: fopr_CRS.h:47
Field
Container of Field-type object.
Definition: field.h:46
Fopr_CRS::m_Nin
int m_Nin
Definition: fopr_CRS.h:45
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Fopr_CRS::DdagD
void DdagD(Field &, const Field &)
Definition: fopr_CRS.cpp:58