Bridge++  Ver. 2.0.2
aeigensolver_IRLanczos.h
Go to the documentation of this file.
1 
14 #ifndef AEIGENSOLVER_IRLANCZOS_INCLUDED
15 #define AEIGENSOLVER_IRLANCZOS_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 
43 template<typename FIELD, typename FOPR>
44 class AEigensolver_IRLanczos : public AEigensolver<FIELD, FOPR>
45 {
46  public:
47  typedef typename FIELD::real_t real_t;
49 
50  static const std::string class_name;
51 
52  private:
54 
55  int m_Nk;
56  int m_Np;
60 
61  std::string m_sort_type;
62 
63  FOPR *m_fopr;
65 
66  std::vector<real_t> m_TDb;
67  std::vector<real_t> m_TDa2;
68  std::vector<real_t> m_TDb2;
69  std::vector<real_t> m_Qt;
70 
71  std::vector<int> m_Iconv;
72 
73  std::vector<FIELD> m_B;
74  FIELD m_f;
75  FIELD m_v;
76 
77  public:
79  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr), m_sorter(0) {}
80 
81  AEigensolver_IRLanczos(FOPR *fopr, const Parameters& params)
82  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr), m_sorter(0)
83  {
84  set_parameters(params);
85  }
86 
88 
89  void set_parameters(const Parameters& params);
90  void set_parameters(int Nk, int Np, int Niter_eigen, double Enorm_eigen,
91  double Vthreshold);
92  void set_parameters(const std::string& sort_type,
93  int Nk, int Np, int Niter_eigen, double Enorm_eigen,
94  double Vthreshold);
95 
96  void get_parameters(Parameters& params) const;
97 
98  void solve(std::vector<real_t>& TDa, std::vector<FIELD>& vk,
99  int& Nsbt, int& Nconv, const FIELD& b);
100 
101  void solve(std::vector<complex_t>& TDa, std::vector<FIELD>& vk,
102  int& Nsbt, int& Nconv, const FIELD& b);
103 
104  private:
105 
106  void step(int Nm, int k,
107  std::vector<real_t>& TDa,
108  std::vector<real_t>& TDb,
109  std::vector<FIELD>& vk, FIELD& f);
110 
111  void qrtrf(std::vector<real_t>& TDa, std::vector<real_t>& TDb,
112  int Nk, int Nm, std::vector<real_t>& Qt,
113  real_t Dsh, int kmin, int kmax);
114 
115  void tqri(std::vector<real_t>& TDa, std::vector<real_t>& TDb,
116  int Nk, int Nm, std::vector<real_t>& Qt, int& nconv);
117 
118  void setUnit_Qt(int Nm, std::vector<real_t>& Qt);
119 
120  void schmidt_orthogonalization(FIELD& w, std::vector<FIELD>& vk, int k);
121 
122 #ifdef USE_FACTORY
123  private:
124  static AEigensolver<FIELD, FOPR> *create_object(FOPR *fopr)
125  { return new AEigensolver_IRLanczos<FIELD, FOPR>(fopr); }
126 
127  static AEigensolver<FIELD, FOPR> *create_object_with_params(FOPR *fopr, const Parameters& params)
128  { return new AEigensolver_IRLanczos<FIELD, FOPR>(fopr, params); }
129 
130  public:
131  static bool register_factory()
132  {
133  bool init = true;
134  init &= AEigensolver<FIELD, FOPR>::Factory_fopr::Register("IRLanczos", create_object);
135  init &= AEigensolver<FIELD, FOPR>::Factory_fopr_params::Register("IRLanczos", create_object_with_params);
136  return init;
137  }
138 #endif
139 };
140 #endif
AEigensolver_IRLanczos::qrtrf
void qrtrf(std::vector< real_t > &TDa, std::vector< real_t > &TDb, int Nk, int Nm, std::vector< real_t > &Qt, real_t Dsh, int kmin, int kmax)
Definition: aeigensolver_IRLanczos-tmpl.h:596
AEigensolver_IRLanczos::setUnit_Qt
void setUnit_Qt(int Nm, std::vector< real_t > &Qt)
Definition: aeigensolver_IRLanczos-tmpl.h:520
AEigensolver_IRLanczos::m_Nk
int m_Nk
Definition: aeigensolver_IRLanczos.h:55
bridgeIO.h
AEigensolver_IRLanczos::m_Np
int m_Np
Definition: aeigensolver_IRLanczos.h:56
AEigensolver_IRLanczos::m_fopr
FOPR * m_fopr
Definition: aeigensolver_IRLanczos.h:63
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
AEigensolver_IRLanczos::m_B
std::vector< FIELD > m_B
Definition: aeigensolver_IRLanczos.h:73
AEigensolver_IRLanczos::m_Enorm_eigen
real_t m_Enorm_eigen
Definition: aeigensolver_IRLanczos.h:58
AEigensolver_IRLanczos::m_TDb2
std::vector< real_t > m_TDb2
Definition: aeigensolver_IRLanczos.h:68
Parameters
Class for parameters.
Definition: parameters.h:46
AEigensolver_IRLanczos::complex_t
ComplexTraits< real_t >::complex_t complex_t
Definition: aeigensolver_IRLanczos.h:48
AEigensolver_IRLanczos::m_Iconv
std::vector< int > m_Iconv
Definition: aeigensolver_IRLanczos.h:71
AEigensolver_IRLanczos::m_sort_type
std::string m_sort_type
Definition: aeigensolver_IRLanczos.h:61
AEigensolver_IRLanczos::m_f
FIELD m_f
Definition: aeigensolver_IRLanczos.h:74
AEigensolver::real_t
FIELD::real_t real_t
Definition: aeigensolver.h:45
AEigensolver_IRLanczos::~AEigensolver_IRLanczos
~AEigensolver_IRLanczos()
Definition: aeigensolver_IRLanczos-tmpl.h:31
AEigensolver_IRLanczos::m_v
FIELD m_v
Definition: aeigensolver_IRLanczos.h:75
AEigensolver_IRLanczos::AEigensolver_IRLanczos
AEigensolver_IRLanczos(FOPR *fopr, const Parameters &params)
Definition: aeigensolver_IRLanczos.h:81
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AEigensolver_IRLanczos::m_TDb
std::vector< real_t > m_TDb
Definition: aeigensolver_IRLanczos.h:66
bridge_complex.h
AEigensolver_IRLanczos::m_Niter_eigen
int m_Niter_eigen
Definition: aeigensolver_IRLanczos.h:57
sorter_alt.h
AEigensolver_IRLanczos::class_name
static const std::string class_name
Definition: aeigensolver_IRLanczos.h:50
AEigensolver_IRLanczos::m_sorter
Sorter< real_t > * m_sorter
Definition: aeigensolver_IRLanczos.h:64
AEigensolver_IRLanczos::step
void step(int Nm, int k, std::vector< real_t > &TDa, std::vector< real_t > &TDb, std::vector< FIELD > &vk, FIELD &f)
Definition: aeigensolver_IRLanczos-tmpl.h:440
AEigensolver_IRLanczos::m_Qt
std::vector< real_t > m_Qt
Definition: aeigensolver_IRLanczos.h:69
AEigensolver_IRLanczos::m_Vthreshold
real_t m_Vthreshold
Definition: aeigensolver_IRLanczos.h:59
ComplexTraits
Definition: complexTraits.h:16
AEigensolver_IRLanczos::AEigensolver_IRLanczos
AEigensolver_IRLanczos(FOPR *fopr)
Definition: aeigensolver_IRLanczos.h:78
AEigensolver_IRLanczos::m_TDa2
std::vector< real_t > m_TDa2
Definition: aeigensolver_IRLanczos.h:67
AEigensolver_IRLanczos
Eigenvalue solver with Implicitly Restarted Lanczos algorithm.
Definition: aeigensolver_IRLanczos.h:44
AEigensolver_IRLanczos::tqri
void tqri(std::vector< real_t > &TDa, std::vector< real_t > &TDb, int Nk, int Nm, std::vector< real_t > &Qt, int &nconv)
Definition: aeigensolver_IRLanczos-tmpl.h:535
AEigensolver_IRLanczos::schmidt_orthogonalization
void schmidt_orthogonalization(FIELD &w, std::vector< FIELD > &vk, int k)
Definition: aeigensolver_IRLanczos-tmpl.h:501
AEigensolver_IRLanczos::real_t
FIELD::real_t real_t
Definition: aeigensolver_IRLanczos.h:47
complexTraits.h
AEigensolver_IRLanczos::m_vl
Bridge::VerboseLevel m_vl
Definition: aeigensolver_IRLanczos.h:53
AEigensolver_IRLanczos::get_parameters
void get_parameters(Parameters &params) const
Definition: aeigensolver_IRLanczos-tmpl.h:74
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Sorter< real_t >
AEigensolver_IRLanczos::set_parameters
void set_parameters(const Parameters &params)
Definition: aeigensolver_IRLanczos-tmpl.h:39
AEigensolver_IRLanczos::solve
void solve(std::vector< real_t > &TDa, std::vector< FIELD > &vk, int &Nsbt, int &Nconv, const FIELD &b)
Definition: aeigensolver_IRLanczos-tmpl.h:183
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AEigensolver
Eigensolver class for abstract base class of eigen solvers.
Definition: aeigensolver.h:42
aeigensolver.h