TBTK
Need a break? Support the development by playing Polarity Puzzles
AbstractState.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_ABSTRACT_STATE
25 #define COM_DAFER45_TBTK_ABSTRACT_STATE
26 
27 #include "TBTK/AbstractOperator.h"
28 #include "TBTK/DefaultOperator.h"
29 #include "TBTK/Index.h"
30 #include "TBTK/Serializable.h"
31 
32 #include <complex>
33 #include <initializer_list>
34 #include <limits>
35 #include <vector>
36 
37 namespace TBTK{
38 
39 class AbstractState : public Serializable{
40 public:
47  enum StateID{
48  Basic = 0,
49  STO3G = 1,
50  Gaussian = 2
51  };
52 
54  AbstractState(StateID stateID);
55 
57  virtual ~AbstractState();
58 
60  virtual AbstractState* clone() const = 0;
61 
66  virtual std::complex<double> getOverlap(const AbstractState &ket) const = 0;
67 
72  virtual std::complex<double> getMatrixElement(
73  const AbstractState &ket,
74  const AbstractOperator &o = DefaultOperator()
75  ) const = 0;
76 
78  StateID getStateID() const;
79 
81  void setCoordinates(std::initializer_list<double> coordinates);
82 
84  void setCoordinates(const std::vector<double> &coordinates);
85 
87  void setSpecifiers(std::initializer_list<int> specifiers);
88 
90  void setSpecifiers(const std::vector<int> &specifiers);
91 
93  void setIndex(const Index &index);
94 
96  void setContainer(const Index &container);
97 
99  void setExtent(double extent);
100 
102  const std::vector<double>& getCoordinates() const;
103 
105  const std::vector<int>& getSpecifiers() const;
106 
108  const Index& getIndex() const;
109 
111  const Index& getContainer() const;
112 
114  double getExtent() const;
115 
117  bool hasFiniteExtent() const;
118 
120  std::string serialize(Mode mode) const;
121 private:
123  StateID stateID;
124 
126  std::vector<double> coordinates;
127 
129  std::vector<int> specifiers;
130 
132  Index index;
133 
136  Index container;
137 
139  double extent;
140 };
141 
142 inline AbstractState::StateID AbstractState::getStateID() const{
143  return stateID;
144 }
145 
146 inline void AbstractState::setIndex(const Index& index){
147  this->index = index;
148 }
149 
150 inline void AbstractState::setContainer(const Index& container){
151  this->container = container;
152 }
153 
154 inline void AbstractState::setExtent(double extent){
155  this->extent = extent;
156 }
157 
158 inline const std::vector<double>& AbstractState::getCoordinates() const{
159  return coordinates;
160 }
161 
162 inline const std::vector<int>& AbstractState::getSpecifiers() const{
163  return specifiers;
164 }
165 
166 inline const Index& AbstractState::getIndex() const{
167  return index;
168 }
169 
170 inline const Index& AbstractState::getContainer() const{
171  return container;
172 }
173 
174 inline double AbstractState::getExtent() const{
175  return extent;
176 }
177 
178 inline bool AbstractState::hasFiniteExtent() const{
179  if(std::numeric_limits<double>::has_infinity)
180  return !(extent == std::numeric_limits<double>::infinity());
181  else
182  return !(extent == std::numeric_limits<double>::max());
183 }
184 
185 }; //End of namespace TBTK
186 
187 #endif
188 
Physical index.
Definition: Boolean.h:32
Abstract base class for serializable objects.