TBTK
AbstractState.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_ABSTRACT_STATE
24 #define COM_DAFER45_TBTK_ABSTRACT_STATE
25 
26 #include "TBTK/AbstractOperator.h"
27 #include "TBTK/DefaultOperator.h"
28 #include "TBTK/Index.h"
29 
30 #include <complex>
31 #include <initializer_list>
32 #include <limits>
33 #include <vector>
34 
35 namespace TBTK{
36 
38 public:
45  enum StateID{
46  Basic = 0
47  };
48 
50  AbstractState(StateID stateID);
51 
53  virtual ~AbstractState();
54 
56  virtual AbstractState* clone() const = 0;
57 
62  virtual std::complex<double> getOverlap(const AbstractState &ket) const = 0;
63 
68  virtual std::complex<double> getMatrixElement(
69  const AbstractState &ket,
71  ) const = 0;
72 
74  StateID getStateID() const;
75 
77  void setCoordinates(std::initializer_list<double> coordinates);
78 
80  void setCoordinates(const std::vector<double> &coordinates);
81 
83  void setSpecifiers(std::initializer_list<int> specifiers);
84 
86  void setSpecifiers(const std::vector<int> &specifiers);
87 
89  void setIndex(const Index &index);
90 
92  void setContainer(const Index &container);
93 
95  void setExtent(double extent);
96 
98  const std::vector<double>& getCoordinates() const;
99 
101  const std::vector<int>& getSpecifiers() const;
102 
104  const Index& getIndex() const;
105 
107  const Index& getContainer() const;
108 
110  double getExtent() const;
111 
113  bool hasFiniteExtent() const;
114 private:
116  StateID stateID;
117 
119  std::vector<double> coordinates;
120 
122  std::vector<int> specifiers;
123 
125  Index index;
126 
129  Index container;
130 
132  double extent;
133 };
134 
136  return stateID;
137 }
138 
139 inline void AbstractState::setIndex(const Index& index){
140  this->index = index;
141 }
142 
143 inline void AbstractState::setContainer(const Index& container){
144  this->container = container;
145 }
146 
147 inline void AbstractState::setExtent(double extent){
148  this->extent = extent;
149 }
150 
151 inline const std::vector<double>& AbstractState::getCoordinates() const{
152  return coordinates;
153 }
154 
155 inline const std::vector<int>& AbstractState::getSpecifiers() const{
156  return specifiers;
157 }
158 
159 inline const Index& AbstractState::getIndex() const{
160  return index;
161 }
162 
163 inline const Index& AbstractState::getContainer() const{
164  return container;
165 }
166 
167 inline double AbstractState::getExtent() const{
168  return extent;
169 }
170 
171 inline bool AbstractState::hasFiniteExtent() const{
172  if(std::numeric_limits<double>::has_infinity)
173  return !(extent == std::numeric_limits<double>::infinity());
174  else
175  return !(extent == std::numeric_limits<double>::max());
176 }
177 
178 }; //End of namespace TBTK
179 
180 #endif
virtual AbstractState * clone() const =0
Flexible physical index.
void setExtent(double extent)
Definition: AbstractState.h:147
StateID getStateID() const
Definition: AbstractState.h:135
const std::vector< double > & getCoordinates() const
Definition: AbstractState.h:151
bool hasFiniteExtent() const
Definition: AbstractState.h:171
double getExtent() const
Definition: AbstractState.h:167
Definition: AbstractOperator.h:30
virtual ~AbstractState()
AbstractState(StateID stateID)
void setIndex(const Index &index)
Definition: AbstractState.h:139
Abstract operator class from which other operators inherit.
Definition: AbstractState.h:37
StateID
Definition: AbstractState.h:45
Flexible physical index.
Definition: Index.h:70
Definition: ModelFactory.h:35
virtual std::complex< double > getMatrixElement(const AbstractState &ket, const AbstractOperator &o=DefaultOperator()) const =0
void setContainer(const Index &container)
Definition: AbstractState.h:143
const Index & getIndex() const
Definition: AbstractState.h:159
void setSpecifiers(std::initializer_list< int > specifiers)
const std::vector< int > & getSpecifiers() const
Definition: AbstractState.h:155
const Index & getContainer() const
Definition: AbstractState.h:163
Default (dummy) operator class for indicating default behavior.
virtual std::complex< double > getOverlap(const AbstractState &ket) const =0
Definition: DefaultOperator.h:30
void setCoordinates(std::initializer_list< double > coordinates)