TBTK
Need a break? Support the development by playing Polarity Puzzles
Range.h
Go to the documentation of this file.
1 /* Copyright 2017 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_RANGE
24 #define COM_DAFER45_TBTK_RANGE
25 
26 #include "TBTK/Serializable.h"
27 #include "TBTK/TBTKMacros.h"
28 
29 #include "TBTK/json.hpp"
30 
31 namespace TBTK{
32 
52 class Range : public Serializable{
53 public:
66  Range(
67  double lowerBound,
68  double upperBound,
69  unsigned int resolution,
70  bool includeLowerBound = true,
71  bool includeUpperBound = true
72  );
73 
80  Range(const std::string &serialization, Mode mode);
81 
85  unsigned int getResolution() const;
86 
92  double operator[](unsigned int n) const;
93 
99  virtual std::string serialize(Mode mode) const;
100 private:
102  double start;
103 
105  double dx;
106 
108  unsigned int resolution;
109 };
110 
111 inline double Range::operator[](unsigned int n) const{
112  return start + n*dx;
113 }
114 
115 inline unsigned int Range::getResolution() const{
116  return resolution;
117 }
118 
119 }; //End of namesapce TBTK
120 
121 #endif
unsigned int getResolution() const
Definition: Range.h:115
Precompiler macros.
Definition: Serializable.h:43
One-dimensional range.
Definition: Range.h:52
Range(double lowerBound, double upperBound, unsigned int resolution, bool includeLowerBound=true, bool includeUpperBound=true)
Definition: Boolean.h:32
Mode
Definition: Serializable.h:47
Abstract base class for serializable objects.
virtual std::string serialize(Mode mode) const
double operator[](unsigned int n) const
Definition: Range.h:111