Bridge++  Ver. 1.1.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Sign.h
Go to the documentation of this file.
1 
14 #ifndef FOPR_SIGN_INCLUDED
15 #define FOPR_SIGN_INCLUDED
16 
17 #include "fopr.h"
18 #include "field_G.h"
19 #include "shiftsolver_CG.h"
20 #include "math_Sign_Zolotarev.h"
21 
22 #include "bridgeIO.h"
23 using Bridge::vout;
24 
26 
47 //- parameters class
48 class Parameters_Fopr_Sign : virtual public Parameters
49 {
50  public:
52 };
53 //- end
54 
55 class Fopr_Sign : public Fopr
56 {
57  private:
58  int m_Np; // number of poles in rational approx.
59  double m_x_min, m_x_max; // valid range of approximate sign function
60  int m_Niter; // max iteration of shiftsolver
61  double m_Stop_cond; // stopping condition of shift solver
62 
64 
65  std::valarray<double> m_cl;
66  std::valarray<double> m_bl;
67  std::valarray<double> m_sigma;
68 
69  //- low-mode subtraction
70  int m_Nsbt;
71  std::valarray<double> *m_ev;
72  std::valarray<Field> *m_vk;
73 
74  //- shiftsolver
76  std::valarray<Field> m_xq;
77 
78  public:
79 
80  Fopr_Sign(Fopr *fopr)
81  : Fopr(), m_fopr(fopr)
82  {
83  m_Nsbt = 0;
84  m_ev = 0;
85  m_vk = 0;
86  }
87 
89  {
90  tidyup();
91  }
92 
93  void set_parameters(const Parameters& params);
94  void set_parameters(int Np, double x_min, double x_max,
95  int Niter, double Stop_cond);
96 
97  void set_config(Field *U)
98  {
99  m_fopr->set_config(U);
100  }
101 
102  void set_mode(std::string mode)
103  {
104  m_fopr->set_mode(mode);
105  }
106 
107  std::string get_mode() const
108  {
109  return m_fopr->get_mode();
110  }
111 
112  void tidyup();
113 
114  void set_lowmodes(int Nsbt, std::valarray<double> *,
115  std::valarray<Field> *);
116 
117  void mult(Field& v, const Field& f);
118 
119  const Field mult(const Field& f)
120  {
121  Field v(f.nin(), f.nvol(), f.nex());
122 
123  mult(v, f);
124 
125  return v;
126  }
127 
128  void mult_dag(Field& v, const Field& f)
129  {
130  mult(v, f);
131  }
132 
133  const Field mult_dag(const Field& f)
134  {
135  Field v(f.nin(), f.nvol(), f.nex());
136 
137  mult_dag(v, f);
138 
139  return v;
140  }
141 
142  int field_nvol() { return m_fopr->field_nvol(); }
143  int field_nin() { return m_fopr->field_nin(); }
144  int field_nex() { return m_fopr->field_nex(); }
145 
146  private:
147  void init_parameters();
148 
149  void subtract_lowmodes(Field&);
150  void evaluate_lowmodes(Field&, const Field&);
151 
152  double sign_zolotarev(double x);
153 };
154 #endif