TBTK
Need a break? Support the development by playing Polarity Puzzles
FockState.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
25 #define COM_DAFER45_TBTK_FOCK_STATE
26 
27 #include "TBTK/Streams.h"
28 
29 namespace TBTK{
30 
31 template<typename BIT_REGISTER>
32 class FockSpace;
33 
34 template<typename BIT_REGISTER>
35 class LadderOperator;
36 
37 template<typename BIT_REGISTER>
38 class FockState{
39 public:
41  FockState(unsigned int exponentialDimension);
42 
44  FockState(const FockState &fockState);
45 
47  ~FockState();
48 
50  bool isNull() const;
51 
53  const BIT_REGISTER& getBitRegister() const;
54 
56  BIT_REGISTER& getBitRegister();
57 
59  int getPrefactor() const;
60 
62 // unsigned int getNumFermions() const;
63 
65  void print() const;
66 private:
68  friend class FockSpace<BIT_REGISTER>;
69 
71  friend class LadderOperator<BIT_REGISTER>;
72 
74  BIT_REGISTER bitRegister;
75 
78  int prefactor;
79 };
80 
81 template<typename BIT_REGISTER>
82 FockState<BIT_REGISTER>::FockState(unsigned int exponentialDimension
83 ) :
84  bitRegister(exponentialDimension+1)
85 {
86  bitRegister.clear();
87  prefactor = 1;
88 }
89 
90 template<typename BIT_REGISTER>
91 FockState<BIT_REGISTER>::FockState(const FockState &fockState
92 ) :
93  bitRegister(fockState.bitRegister)
94 {
95  prefactor = fockState.prefactor;
96 }
97 
98 template<typename BIT_REGISTER>
99 FockState<BIT_REGISTER>::~FockState(){
100 }
101 
102 template<typename BIT_REGISTER>
103 bool FockState<BIT_REGISTER>::isNull() const{
104  return bitRegister.getMostSignificantBit();
105 }
106 
107 template<typename BIT_REGISTER>
108 const BIT_REGISTER& FockState<BIT_REGISTER>::getBitRegister() const{
109  return bitRegister;
110 }
111 
112 template<typename BIT_REGISTER>
113 BIT_REGISTER& FockState<BIT_REGISTER>::getBitRegister(){
114  return bitRegister;
115 }
116 
117 template<typename BIT_REGISTER>
118 int FockState<BIT_REGISTER>::getPrefactor() const{
119  return prefactor;
120 }
121 
122 /*template<typename BIT_REGISTER>
123 unsigned int FockState<BIT_REGISTER>::getNumFermions() const{
124  return bitRegister.getNumOneBits();
125 }*/
126 
127 template<typename BIT_REGISTER>
128 void FockState<BIT_REGISTER>::print() const{
129  Streams::out << prefactor << "|";
130  for(int n = bitRegister.getNumBits()-1; n >= 0; n--){
131  Streams::out << bitRegister.getBit(n);
132  if(n%8 == 0 && n != 0)
133  Streams::out << " ";
134  }
135  Streams::out << ">\n";
136 }
137 
138 }; //End of namespace TBTK
139 
140 #endif
141 
static std::ostream out
Definition: Streams.h:70
Definition: Boolean.h:32
Streams for TBTK output.