TBTK
Need a break? Support the development by playing Polarity Puzzles
InteractionAmplitude.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_INTERACTION_AMPLITUDE
25 #define COM_DAFER45_TBTK_INTERACTION_AMPLITUDE
26 
27 #include "TBTK/Index.h"
28 
29 #include <complex>
30 #include <initializer_list>
31 
32 namespace TBTK{
33 
34 class InteractionAmplitude{
35 public:
37  InteractionAmplitude();
38 
40  InteractionAmplitude(
41  std::complex<double> amplitude,
42  std::initializer_list<Index> creationOperatorIndices,
43  std::initializer_list<Index> annihilationOperatorIndices
44  );
45 
49  InteractionAmplitude(
50  std::complex<double> (*amplitudeCallback)(const std::vector<Index>&, const std::vector<Index>&),
51  std::initializer_list<Index> toIndex,
52  std::initializer_list<Index> fromIndex
53  );
54 
56  InteractionAmplitude(const InteractionAmplitude &ia);
57 
59  ~InteractionAmplitude();
60 
64  std::complex<double> getAmplitude() const;
65 
67  unsigned int getNumCreationOperators() const;
68 
70  unsigned int getNumAnnihilationOperators() const;
71 
73  const Index& getCreationOperatorIndex(unsigned int n) const;
74 
76  const Index& getAnnihilationOperatorIndex(unsigned int n) const;
77 private:
79  std::complex<double> amplitude;
80 
83  std::complex<double> (*amplitudeCallback)(
84  const std::vector<Index> &toIndex,
85  const std::vector<Index> &fromIndex
86  );
87 
89  std::vector<Index> creationOperatorIndices;
90 
92  std::vector<Index> annihilationOperatorIndices;
93 };
94 
95 inline std::complex<double> InteractionAmplitude::getAmplitude() const{
96  if(amplitudeCallback)
97  return amplitudeCallback(creationOperatorIndices, annihilationOperatorIndices);
98  else
99  return amplitude;
100 }
101 
102 inline unsigned int InteractionAmplitude::getNumCreationOperators() const{
103  return creationOperatorIndices.size();
104 }
105 
106 inline unsigned int InteractionAmplitude::getNumAnnihilationOperators() const{
107  return annihilationOperatorIndices.size();
108 }
109 
110 inline const Index& InteractionAmplitude::getCreationOperatorIndex(unsigned int n) const{
111  return creationOperatorIndices.at(n);
112 }
113 
114 inline const Index& InteractionAmplitude::getAnnihilationOperatorIndex(unsigned int n) const{
115  return annihilationOperatorIndices.at(n);
116 }
117 
118 }; //End of namespace TBTK
119 
120 #endif
121 
Physical index.
Definition: Boolean.h:32