One-dimensional range.
More...
#include <Range.h>
|
| Range (double lowerBound, double upperBound, unsigned int resolution, bool includeLowerBound=true, bool includeUpperBound=true) |
|
| Range (const std::string &serialization, Mode mode) |
|
unsigned int | getResolution () const |
|
double | operator[] (unsigned int n) const |
|
virtual std::string | serialize (Mode mode) const |
|
template<> |
std::string | serialize (const bool &data, Mode mode) |
|
template<> |
std::string | serialize (const double &data, Mode mode) |
|
template<> |
std::string | serialize (const std::complex< double > &data, Mode mode) |
|
template<> |
std::string | serialize (const int &data, Mode mode) |
|
template<> |
std::string | serialize (const unsigned int &data, Mode mode) |
|
template<> |
std::string | serialize (const SpinMatrix &data, Mode mode) |
|
template<> |
std::string | serialize (const Statistics &data, Mode mode) |
|
template<> |
std::string | serialize (const std::vector< std::complex< double >> &data, Mode mode) |
|
template<> |
int | deserialize (const std::string &serialization, Mode mode) |
|
|
enum | Mode { Debug,
Binary,
XML,
JSON
} |
|
static bool | hasID (const std::string &serialization, Mode mode) |
|
static std::string | getID (const std::string &serialization, Mode mode) |
|
static std::string | extractComponent (const std::string &serialization, const std::string &containerID, const std::string &componentID, const std::string &componentName, Mode mode) |
|
static bool | validate (const std::string &serialization, const std::string &id, Mode mode) |
|
static std::string | getContent (const std::string &serialization, Mode mode) |
|
static std::vector< std::string > | split (const std::string &content, Mode mode) |
|
template<typename DataType > |
static std::enable_if<!std::is_pointer< DataType >::value, std::string >::type | serialize (const DataType &data, Mode mode) |
|
template<typename DataType > |
static std::enable_if< std::is_pointer< DataType >::value, std::string >::type | serialize (const DataType &data, Mode mode) |
|
template<typename DataType > |
static DataType | deserialize (const std::string &serialization, Mode mode) |
|
static std::string | extract (const std::string &serialization, Mode mode, std::string component) |
|
One-dimensional range.
The Range can be used to define a one-dimensional interval. It has a lower and upper bound, an is resolved with a number of points. A Range is created using
Range range(LOWER_BOUND, UPPER_BOUND, RESOLUTION);
Bounds
By default the bounds are included in the Range. But it is possible to exclude one or both bounds by passing two add boolean flags to the constructor. The first and second flag indicates whether the lower and upper bounds are included, respectively.
Example
using namespace std;
using namespace TBTK;
void print(
const Range &range){
if(n != 0)
}
}
int main(){
print(range);
range =
Range(-1, 1, 5,
false,
true);
print(range);
range =
Range(-1, 1, 5,
true,
false);
print(range);
range =
Range(-1, 1, 5,
false,
false);
print(range);
}
Output
Range [-1, 1]: -1, -0.5, 0, 0.5, 1
Range (-1, 1]: -0.6, -0.2, 0.2, 0.6, 1
Range [-1, 1): -1, -0.6, -0.2, 0.2, 0.6
Range (-1, 1): -0.666667, -0.333333, -1.11022e-16, 0.333333, 0.666667
◆ Range() [1/2]
TBTK::Range::Range |
( |
double |
lowerBound, |
|
|
double |
upperBound, |
|
|
unsigned int |
resolution, |
|
|
bool |
includeLowerBound = true , |
|
|
bool |
includeUpperBound = true |
|
) |
| |
Constructor.
- Parameters
-
lowerBound | The lower bound of the range. |
TupperBound | The upper bound of the range. |
resolution | The number of points with which to resolve the range. |
includeLowerBound | Flag indicating whether or not the lower bound should be included. |
includeUpperBound | Flag indicating whether or not the upper bound should be included. |
◆ Range() [2/2]
TBTK::Range::Range |
( |
const std::string & |
serialization, |
|
|
Mode |
mode |
|
) |
| |
Constructor. Constructs the Range from a serialization string.
- Parameters
-
serialization | Serialization string from which to construct the Range. |
mode | The mode with which the string has been serialized. |
◆ getResolution()
unsigned int TBTK::Range::getResolution |
( |
| ) |
const |
|
inline |
Get resolution.
- Returns
- The number of points with which the range is resolved.
◆ operator[]()
double TBTK::Range::operator[] |
( |
unsigned int |
n | ) |
const |
|
inline |
Array subscript operator.
- Parameters
-
n | The index of the entry to return. |
- Returns
- The nth entry in the Range.
◆ serialize()
virtual std::string TBTK::Range::serialize |
( |
Mode |
mode | ) |
const |
|
virtual |
The documentation for this class was generated from the following file:
- /TBTK/Lib/include/Utilities/TBTK/Range.h