TBTK
Need a break? Support the development by playing Polarity Puzzles
FockStateRuleSet.h
1 /* Copyright 2016 Kristofer Björnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
17 
24 #ifndef COM_DAFER45_TBTK_FOCK_STATE_RULE_SET
25 #define COM_DAFER45_TBTK_FOCK_STATE_RULE_SET
26 
27 #include "TBTK/FockStateRule/FockStateRule.h"
28 #include "TBTK/FockStateRule/WrapperRule.h"
29 
30 #include <vector>
31 
32 namespace TBTK{
33 
34 class FockStateRuleSet{
35 public:
37  FockStateRuleSet();
38 
40  ~FockStateRuleSet();
41 
44  bool isSatisfied(
45  const FockSpace<BitRegister> &fockSpace,
46  const FockState<BitRegister> &fockState
47  ) const;
48 
51  bool isSatisfied(
52  const FockSpace<ExtensiveBitRegister> &fockSpace,
53  const FockState<ExtensiveBitRegister> &fockState
54  ) const;
55 
57  void addFockStateRule(const FockStateRule::WrapperRule &fockStateRule);
58 
60  unsigned int getSize() const;
61 
63  bool operator==(const FockStateRuleSet &rhs) const;
64 
69  friend FockStateRuleSet operator*(
70  const LadderOperator<BitRegister> &ladderOperator,
71  const FockStateRuleSet &fockStateRuleSet
72  );
73 
78  friend FockStateRuleSet operator*(
79  const LadderOperator<ExtensiveBitRegister> &ladderOperator,
80  const FockStateRuleSet &fockStateRuleSet
81  );
82 
84  void print() const;
85 private:
87  std::vector<FockStateRule::WrapperRule> fockStateRules;
88 };
89 
90 inline void FockStateRuleSet::addFockStateRule(
91  const FockStateRule::WrapperRule &fockStateRule
92 ){
93  for(unsigned int n = 0; n < fockStateRules.size(); n++)
94  if(fockStateRules.at(n) == fockStateRule)
95  return;
96 
97  fockStateRules.push_back(fockStateRule);
98 }
99 
100 inline unsigned int FockStateRuleSet::getSize() const{
101  return fockStateRules.size();
102 }
103 
104 inline FockStateRuleSet operator*(
105  const LadderOperator<BitRegister> &ladderOperator,
106  const FockStateRuleSet &fockStateRuleSet
107 ){
108  FockStateRuleSet newRuleSet;
109  for(unsigned int n = 0; n < fockStateRuleSet.fockStateRules.size(); n++)
110  newRuleSet.addFockStateRule(ladderOperator*fockStateRuleSet.fockStateRules.at(n));
111 
112  return newRuleSet;
113 }
114 
115 inline FockStateRuleSet operator*(
116  const LadderOperator<ExtensiveBitRegister> &ladderOperator,
117  const FockStateRuleSet &fockStateRuleSet
118 ){
119  FockStateRuleSet newRuleSet;
120  for(unsigned int n = 0; n < fockStateRuleSet.fockStateRules.size(); n++)
121  newRuleSet.addFockStateRule(ladderOperator*fockStateRuleSet.fockStateRules.at(n));
122 
123  return newRuleSet;
124 }
125 
126 inline void FockStateRuleSet::print() const{
127  Streams::out << "FockStateRuleSet{\n";
128  for(unsigned int n = 0; n < fockStateRules.size(); n++){
129  if(n > 0)
130  Streams::out << ",\n";
131  Streams::out << "\t";
132  fockStateRules.at(n).print();
133  }
134  Streams::out << "\n}\n";
135 }
136 
137 }; //End of namespace TBTK
138 
139 #endif
140 
static std::ostream out
Definition: Streams.h:70
Definition: Boolean.h:32
const Vector2d operator*(double lhs, const Vector2d &rhs)
Definition: Vector2d.h:129