TBTK
HoppingAmplitude.h
Go to the documentation of this file.
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 
23 #ifndef COM_DAFER45_TBTK_HOPPING_AMPLITUDE
24 #define COM_DAFER45_TBTK_HOPPING_AMPLITUDE
25 
26 #include "TBTK/Index.h"
27 #include "TBTK/Serializable.h"
28 
29 #include <complex>
30 #include <initializer_list>
31 #include <tuple>
32 #include <vector>
33 
34 namespace TBTK{
35 
38 
50 public:
61  std::complex<double> amplitude,
62  Index toIndex,
63  Index fromIndex
64  );
65 
79  std::complex<double> (*amplitudeCallback)(
80  const Index &to,
81  const Index &from
82  ),
83  Index toIndex,
84  Index fromIndex
85  );
86 
91 
100  const std::string &serializeation,
101  Serializable::Mode mode
102  );
103 
108 
110  void print() const;
111 
115  std::complex<double> getAmplitude() const;
116 
125  std::tuple<HoppingAmplitude, HoppingAmplitude> operator+(
126  const HermitianConjugate hc
127  );
128 
132  const Index& getToIndex() const;
133 
137  const Index& getFromIndex() const;
138 
142  std::string toString() const;
143 
152  std::string serialize(Serializable::Mode mode) const;
153 
157  unsigned int getSizeInBytes() const;
158 private:
161  std::complex<double> amplitude;
162 
165  std::complex<double> (*amplitudeCallback)(
166  const Index &toIndex,
167  const Index &fromIndex
168  );
169 
171  Index fromIndex;
172 
174  Index toIndex;
175 
176 };
177 
178 inline std::complex<double> HoppingAmplitude::getAmplitude() const{
179  if(amplitudeCallback)
180  return amplitudeCallback(toIndex, fromIndex);
181  else
182  return amplitude;
183 }
184 
185 inline std::tuple<HoppingAmplitude, HoppingAmplitude> HoppingAmplitude::operator+(
187 ){
188  return std::make_tuple(*this, this->getHermitianConjugate());
189 }
190 
191 inline const Index& HoppingAmplitude::getToIndex() const{
192  return toIndex;
193 }
194 
195 inline const Index& HoppingAmplitude::getFromIndex() const{
196  return fromIndex;
197 }
198 
199 inline std::string HoppingAmplitude::toString() const{
200  std::string str;
201  str += "("
202  + std::to_string(real(amplitude))
203  + ", " + std::to_string(imag(amplitude))
204  + ")"
205  + ", " + toIndex.toString()
206  + ", " + fromIndex.toString();
207 
208  return str;
209 }
210 
211 inline unsigned int HoppingAmplitude::getSizeInBytes() const{
212  return sizeof(HoppingAmplitude)
213  - sizeof(fromIndex)
214  - sizeof(toIndex)
215  + fromIndex.getSizeInBytes()
216  + toIndex.getSizeInBytes();
217 }
218 
219 }; //End of namespace TBTK
220 
221 #endif
std::tuple< HoppingAmplitude, HoppingAmplitude > operator+(const HermitianConjugate hc)
Definition: HoppingAmplitude.h:185
Flexible physical index.
const Index & getFromIndex() const
Definition: HoppingAmplitude.h:195
unsigned int getSizeInBytes() const
Definition: Index.h:384
const Index & getToIndex() const
Definition: HoppingAmplitude.h:191
std::complex< double > getAmplitude() const
Definition: HoppingAmplitude.h:178
Hopping amplitude from state &#39;from&#39; to state &#39;to&#39;.
Definition: HoppingAmplitude.h:49
Flexible physical index.
Definition: Index.h:70
Definition: ModelFactory.h:35
HermitianConjugate
Enum used to indicate the Hermitian conjugate.
Definition: HoppingAmplitude.h:37
Mode
Definition: Serializable.h:44
HoppingAmplitude(std::complex< double > amplitude, Index toIndex, Index fromIndex)
unsigned int getSizeInBytes() const
Definition: HoppingAmplitude.h:211
std::string serialize(Serializable::Mode mode) const
Abstract base class for serializable objects.
std::string toString() const
Definition: HoppingAmplitude.h:199
std::string toString() const
Definition: Index.h:265
HoppingAmplitude getHermitianConjugate() const