|
| 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) |
|
template<> |
unsigned int | deserialize (const std::string &serialization, Mode mode) |
|
template<> |
double | deserialize (const std::string &serialization, Mode mode) |
|
template<> |
std::complex< double > | deserialize (const std::string &serialization, Mode mode) |
|
template<> |
SpinMatrix | deserialize (const std::string &serialization, Mode mode) |
|
template<> |
Statistics | deserialize (const std::string &serialization, Mode mode) |
|
template<> |
std::vector< std::complex< double > > | 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;
void print(
const Range &range){
if(n != 0)
Streams::out << ", ";
Streams::out << range[n];
}
}
int main(){
Streams::out << "Range [-1, 1]: ";
print(range);
Streams::out << "\nRange (-1, 1]: ";
range =
Range(-1, 1, 5,
false,
true);
print(range);
Streams::out << "\nRange [-1, 1): ";
range =
Range(-1, 1, 5,
true,
false);
print(range);
Streams::out << "\nRange (-1, 1): ";
range =
Range(-1, 1, 5,
false,
false);
print(range);
Streams::out << "\n";
}
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