Bridge++  Ver. 2.0.2
aeigensolver_IRArnoldi.h
Go to the documentation of this file.
1 
14 #ifndef AEIGENSOLVER_IRARNOLDI_INCLUDED
15 #define AEIGENSOLVER_IRARNOLDI_INCLUDED
16 
17 #include <vector>
18 
19 #include "Eigen/aeigensolver.h"
20 #include "Tools/sorter_alt.h"
21 #include "bridge_complex.h"
22 #include "complexTraits.h"
23 
24 #include "IO/bridgeIO.h"
25 using Bridge::vout;
26 
28 
35 template<typename FIELD, typename FOPR>
36 class AEigensolver_IRArnoldi : public AEigensolver<FIELD, FOPR>
37 {
38  public:
39  typedef typename FIELD::real_t real_t;
41 
42  static const std::string class_name;
43 
44  private:
46 
47  int m_Nk;
48  int m_Np;
49  int m_Nm;
53 
54  std::string m_sort_type;
55 
56  FOPR *m_fopr;
58 
59  std::vector<complex_t> m_TDa2;
60  std::vector<complex_t> m_Qt;
61 
62  std::vector<complex_t> m_Ht;
63  std::vector<complex_t> m_Ht2;
64  std::vector<complex_t> m_Yt;
65 
66  std::vector<int> m_Iconv;
67 
68  std::vector<FIELD> m_B;
69  FIELD m_f;
70  FIELD m_v;
71 
72  public:
74  : m_vl(CommonParameters::Vlevel()),
75  m_fopr(fopr), m_sorter(0) {}
76 
77  AEigensolver_IRArnoldi(FOPR *fopr, const Parameters& params)
78  : m_vl(CommonParameters::Vlevel()),
79  m_fopr(fopr), m_sorter(0)
80  {
81  set_parameters(params);
82  }
83 
85 
86  void set_parameters(const Parameters& params);
87  void set_parameters(int Nk, int Np, int Niter_eigen,
88  double Enorm_eigen, double Vthreshold);
89  void set_parameters(const std::string& sort_type,
90  int Nk, int Np, int Niter_eigen,
91  double Enorm_eigen, double Vthreshold);
92 
93  void get_parameters(Parameters& params) const;
94 
95  void solve(std::vector<complex_t>& TDa, std::vector<FIELD>& vk,
96  int& Nsbt, int& Nconv, const FIELD& b);
97 
98  private:
99 
100  void step(int Nm, int k,
101  std::vector<FIELD>& vk, FIELD& f);
102 
104  void deflation(int k1, int k2, int Kdis,
105  std::vector<complex_t>& TDa,
106  std::vector<FIELD>& vk,
107  complex_t& beta);
108 
109 
110  void qrtrf(std::vector<complex_t>& Ht,
111  int Nk, int Nm, std::vector<complex_t>& Qt,
112  complex_t Dsh, int kmin, int kmax);
113 
114  // void tqri(std::vector<complex_t>& Ht,
115  // int Nk, int Nm, std::vector<complex_t>& Qt, int& nconv);
116  void tqri(std::vector<complex_t>& Ht, int k1,
117  int Nk, int Nm, std::vector<complex_t>& Qt, int& nconv);
118 
119  void setUnit_Qt(int Nm, std::vector<complex_t>& Qt);
120 
121  void schmidt(int Nk, std::vector<FIELD>& vk);
122 
123  void shift_wilkinson(complex_t& kappa,
124  const complex_t a, const complex_t b,
125  const complex_t c, const complex_t d);
126 
127  void check_Qt(const int Nk, const int Nm,
128  std::vector<complex_t>& Qt,
129  std::vector<complex_t>& Ht,
130  std::vector<complex_t>& At);
131 
132  void eigenvector_Ht(std::vector<complex_t>& Yt,
133  std::vector<complex_t>& St,
134  int km, int Nm);
135 
137  void mult_Qt(std::vector<complex_t>& Yt,
138  std::vector<complex_t>& Qt,
139  std::vector<complex_t>& Xt,
140  int km, int Nm);
141 
142  void check_eigen_Ht(std::vector<complex_t>& Ht,
143  std::vector<complex_t>& TDa,
144  std::vector<complex_t>& Xt,
145  int km, int Nm);
146 
147  void reconst_Ht(std::vector<complex_t>& Ht,
148  std::vector<complex_t>& Qt,
149  complex_t& beta,
150  std::vector<FIELD>& vk, int Nk);
151 
152  void reunit_Qt(std::vector<complex_t>& Qt, int Nk);
153 
154  inline int index(int i, int j) { return j + i * m_Nm; }
155  // note that i can be Nm. max: i = Nm, j = Nm-1,
156  // j+i*Nm = Nm-1 + Nm*Nm = (Nm+1)*Nm-1, size = (Nm+1)*Nm.
157 
158 #ifdef USE_FACTORY
159  private:
160  static AEigensolver<FIELD, FOPR> *create_object(FOPR *fopr)
161  { return new AEigensolver_IRArnoldi<FIELD, FOPR>(fopr); }
162 
163  static AEigensolver<FIELD, FOPR> *create_object_with_params(FOPR *fopr, const Parameters& params)
164  { return new AEigensolver_IRArnoldi<FIELD, FOPR>(fopr, params); }
165 
166  public:
167  static bool register_factory()
168  {
169  bool init = true;
170  init &= AEigensolver<FIELD, FOPR>::Factory_fopr::Register("IRArnoldi", create_object);
171  init &= AEigensolver<FIELD, FOPR>::Factory_fopr_params::Register("IRArnoldi", create_object_with_params);
172  return init;
173  }
174 #endif
175 };
176 #endif
AEigensolver_IRArnoldi::m_Vthreshold
real_t m_Vthreshold
given as an absolute value
Definition: aeigensolver_IRArnoldi.h:52
bridgeIO.h
AEigensolver_IRArnoldi::complex_t
ComplexTraits< real_t >::complex_t complex_t
Definition: aeigensolver_IRArnoldi.h:40
AEigensolver_IRArnoldi::m_fopr
FOPR * m_fopr
Definition: aeigensolver_IRArnoldi.h:56
AEigensolver_IRArnoldi::index
int index(int i, int j)
Definition: aeigensolver_IRArnoldi.h:154
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
AEigensolver_IRArnoldi::AEigensolver_IRArnoldi
AEigensolver_IRArnoldi(FOPR *fopr, const Parameters &params)
Definition: aeigensolver_IRArnoldi.h:77
Parameters
Class for parameters.
Definition: parameters.h:46
AEigensolver_IRArnoldi::reconst_Ht
void reconst_Ht(std::vector< complex_t > &Ht, std::vector< complex_t > &Qt, complex_t &beta, std::vector< FIELD > &vk, int Nk)
Definition: aeigensolver_IRArnoldi-tmpl.h:1007
AEigensolver_IRArnoldi::m_B
std::vector< FIELD > m_B
Definition: aeigensolver_IRArnoldi.h:68
AEigensolver_IRArnoldi::m_Ht
std::vector< complex_t > m_Ht
Hessenberg matrix.
Definition: aeigensolver_IRArnoldi.h:62
AEigensolver_IRArnoldi::solve
void solve(std::vector< complex_t > &TDa, std::vector< FIELD > &vk, int &Nsbt, int &Nconv, const FIELD &b)
complex version of solve.
Definition: aeigensolver_IRArnoldi-tmpl.h:170
AEigensolver_IRArnoldi::get_parameters
void get_parameters(Parameters &params) const
Definition: aeigensolver_IRArnoldi-tmpl.h:74
AEigensolver_IRArnoldi::m_sorter
Sorter< complex_t > * m_sorter
Definition: aeigensolver_IRArnoldi.h:57
AEigensolver::real_t
FIELD::real_t real_t
Definition: aeigensolver.h:45
AEigensolver_IRArnoldi::set_parameters
void set_parameters(const Parameters &params)
Definition: aeigensolver_IRArnoldi-tmpl.h:39
AEigensolver_IRArnoldi::qrtrf
void qrtrf(std::vector< complex_t > &Ht, int Nk, int Nm, std::vector< complex_t > &Qt, complex_t Dsh, int kmin, int kmax)
Definition: aeigensolver_IRArnoldi-tmpl.h:685
AEigensolver_IRArnoldi::check_eigen_Ht
void check_eigen_Ht(std::vector< complex_t > &Ht, std::vector< complex_t > &TDa, std::vector< complex_t > &Xt, int km, int Nm)
Definition: aeigensolver_IRArnoldi-tmpl.h:939
AEigensolver_IRArnoldi::m_Nk
int m_Nk
Definition: aeigensolver_IRArnoldi.h:47
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AEigensolver_IRArnoldi::real_t
FIELD::real_t real_t
Definition: aeigensolver_IRArnoldi.h:39
AEigensolver_IRArnoldi::m_f
FIELD m_f
Definition: aeigensolver_IRArnoldi.h:69
AEigensolver_IRArnoldi::m_Enorm_eigen
real_t m_Enorm_eigen
Definition: aeigensolver_IRArnoldi.h:51
AEigensolver_IRArnoldi::tqri
void tqri(std::vector< complex_t > &Ht, int k1, int Nk, int Nm, std::vector< complex_t > &Qt, int &nconv)
Definition: aeigensolver_IRArnoldi-tmpl.h:615
AEigensolver_IRArnoldi::m_vl
Bridge::VerboseLevel m_vl
Definition: aeigensolver_IRArnoldi.h:45
AEigensolver_IRArnoldi::shift_wilkinson
void shift_wilkinson(complex_t &kappa, const complex_t a, const complex_t b, const complex_t c, const complex_t d)
Definition: aeigensolver_IRArnoldi-tmpl.h:842
AEigensolver_IRArnoldi::reunit_Qt
void reunit_Qt(std::vector< complex_t > &Qt, int Nk)
Definition: aeigensolver_IRArnoldi-tmpl.h:972
bridge_complex.h
sorter_alt.h
AEigensolver_IRArnoldi::m_sort_type
std::string m_sort_type
Definition: aeigensolver_IRArnoldi.h:54
AEigensolver_IRArnoldi::AEigensolver_IRArnoldi
AEigensolver_IRArnoldi(FOPR *fopr)
Definition: aeigensolver_IRArnoldi.h:73
AEigensolver_IRArnoldi::check_Qt
void check_Qt(const int Nk, const int Nm, std::vector< complex_t > &Qt, std::vector< complex_t > &Ht, std::vector< complex_t > &At)
Definition: aeigensolver_IRArnoldi-tmpl.h:797
AEigensolver_IRArnoldi::~AEigensolver_IRArnoldi
~AEigensolver_IRArnoldi()
Definition: aeigensolver_IRArnoldi-tmpl.h:31
AEigensolver_IRArnoldi::m_Np
int m_Np
Definition: aeigensolver_IRArnoldi.h:48
AEigensolver_IRArnoldi::m_Iconv
std::vector< int > m_Iconv
Definition: aeigensolver_IRArnoldi.h:66
AEigensolver_IRArnoldi::step
void step(int Nm, int k, std::vector< FIELD > &vk, FIELD &f)
Definition: aeigensolver_IRArnoldi-tmpl.h:545
ComplexTraits
Definition: complexTraits.h:16
AEigensolver_IRArnoldi::class_name
static const std::string class_name
Definition: aeigensolver_IRArnoldi.h:42
AEigensolver_IRArnoldi::m_Yt
std::vector< complex_t > m_Yt
Definition: aeigensolver_IRArnoldi.h:64
AEigensolver_IRArnoldi::m_Ht2
std::vector< complex_t > m_Ht2
temporary Hessenberg matrix
Definition: aeigensolver_IRArnoldi.h:63
AEigensolver_IRArnoldi::m_Qt
std::vector< complex_t > m_Qt
Definition: aeigensolver_IRArnoldi.h:60
AEigensolver_IRArnoldi::m_TDa2
std::vector< complex_t > m_TDa2
Definition: aeigensolver_IRArnoldi.h:59
AEigensolver_IRArnoldi::deflation
void deflation(int k1, int k2, int Kdis, std::vector< complex_t > &TDa, std::vector< FIELD > &vk, complex_t &beta)
deflation of converged eigenvectors.
Definition: aeigensolver_IRArnoldi-tmpl.h:510
complex_t
ComplexTraits< double >::complex_t complex_t
Definition: afopr_Clover_coarse_double.cpp:23
AEigensolver_IRArnoldi::schmidt
void schmidt(int Nk, std::vector< FIELD > &vk)
Definition: aeigensolver_IRArnoldi-tmpl.h:582
AEigensolver_IRArnoldi::m_Nm
int m_Nm
Nm = Nk + Np.
Definition: aeigensolver_IRArnoldi.h:49
AEigensolver_IRArnoldi::eigenvector_Ht
void eigenvector_Ht(std::vector< complex_t > &Yt, std::vector< complex_t > &St, int km, int Nm)
Definition: aeigensolver_IRArnoldi-tmpl.h:885
AEigensolver_IRArnoldi::m_Niter_eigen
int m_Niter_eigen
Definition: aeigensolver_IRArnoldi.h:50
AEigensolver_IRArnoldi::m_v
FIELD m_v
Definition: aeigensolver_IRArnoldi.h:70
complexTraits.h
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Sorter< complex_t >
AEigensolver_IRArnoldi::mult_Qt
void mult_Qt(std::vector< complex_t > &Yt, std::vector< complex_t > &Qt, std::vector< complex_t > &Xt, int km, int Nm)
Yt = Qt * Xt.
Definition: aeigensolver_IRArnoldi-tmpl.h:920
AEigensolver_IRArnoldi::setUnit_Qt
void setUnit_Qt(int Nm, std::vector< complex_t > &Qt)
Definition: aeigensolver_IRArnoldi-tmpl.h:600
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AEigensolver_IRArnoldi
Eigenvalue solver with Implicitly Restarted Arnoldi algorithm.
Definition: aeigensolver_IRArnoldi.h:36
AEigensolver
Eigensolver class for abstract base class of eigen solvers.
Definition: aeigensolver.h:42
aeigensolver.h