TBTK
ExactDiagonalizer.h
1 #ifndef COM_DAFER45_TBTK_SOLVER_EXACT_DIAGONALIZATION
2 #define COM_DAFER45_TBTK_SOLVER_EXACT_DIAGONALIZATION
3 
4 #include "TBTK/Solver/Diagonalizer.h"
6 #include "TBTK/InteractionAmplitudeSet.h"
7 #include "TBTK/Model.h"
9 #include "TBTK/Solver/Solver.h"
10 #include "TBTK/WrapperRule.h"
11 
12 #include <initializer_list>
13 
14 namespace TBTK{
15 namespace Solver{
16 
17 class ExactDiagonalizer : public Solver{
18 public:
21 // Model *model
22  );
23 
25  virtual ~ExactDiagonalizer();
26 
28  unsigned int addSubspace(std::initializer_list<const FockStateRule::WrapperRule> rules);
29 
31  unsigned int addSubspace(std::vector<FockStateRule::WrapperRule> rules);
32 
34  unsigned int addSubspace(const FockStateRuleSet &rules);
35 
37  void run(unsigned int subspace);
38 
40  const double* getEigenValues(unsigned int subspace);
41 
43  const double getEigenValue(unsigned int subspace, int state);
44 
50  const std::complex<double> getAmplitude(
51  unsigned int subspace,
52  int state,
53  const Index &index
54  );
55 
57 // Model* getModel();
58 private:
60 // Model *model;
61 
64  class SubspaceContext{
65  public:
67  SubspaceContext(
68  std::initializer_list<const FockStateRule::WrapperRule> rules
69  );
70 
72  SubspaceContext(
73  std::vector<FockStateRule::WrapperRule> rules
74  );
75 
77  SubspaceContext(
78  const FockStateRuleSet &rules
79  );
80 
82  ~SubspaceContext();
83 
85 // std::vector<FockStateRule::WrapperRule> rules;
86  FockStateRuleSet fockStateRuleSet;
87 
89 // Model *manyParticleModel;
90  std::shared_ptr<Model> manyParticleModel;
91 
93 // Diagonalizer *dSolver;
94  std::shared_ptr<Diagonalizer> dSolver;
95  private:
96  };
97 
99  std::vector<SubspaceContext> subspaceContexts;
100 
102  void setupManyParticleModel(unsigned int subspace);
103 
105  template<typename BIT_REGISTER>
106  void setupManyParticleModel(unsigned int subspace);
107 };
108 
109 inline const double* ExactDiagonalizer::getEigenValues(unsigned int subspace){
110  return subspaceContexts.at(subspace).dSolver->getEigenValues();
111 }
112 
114  unsigned int subspace,
115  int state
116 ){
117  return subspaceContexts.at(subspace).dSolver->getEigenValue(state);
118 }
119 
120 inline const std::complex<double> ExactDiagonalizer::getAmplitude(
121  unsigned int subspace,
122  int state,
123  const Index &index
124 ){
125  return subspaceContexts.at(subspace).dSolver->getAmplitude(
126  state,
127  index
128  );
129 }
130 
131 /*inline Model* ExactDiagonalizer::getModel(){
132  return model;
133 }*/
134 
135 }; //End of namespace Solver
136 }; //End of namespace TBTK
137 
138 #endif
Many-particle context.
Base class for Solvers.
Definition: Solver.h:32
const double * getEigenValues(unsigned int subspace)
Definition: ExactDiagonalizer.h:109
Container of Model related information.
unsigned int addSubspace(std::initializer_list< const FockStateRule::WrapperRule > rules)
Definition: ExactDiagonalizer.h:17
Base class for Solvers.
FockStateRuleSet.
Flexible physical index.
Definition: Index.h:69
Definition: ModelFactory.h:35
void run(unsigned int subspace)
WrapperRule.
Definition: FockStateRuleSet.h:33
const double getEigenValue(unsigned int subspace, int state)
Definition: ExactDiagonalizer.h:113