SSAGES
0.1
A MetaDynamics Package
|
#include <Histogram.h>
Classes | |
class | HistIterator |
Custom Iterator. More... | |
Public Types | |
typedef HistIterator< T > | iterator |
Custom iterator over a histogram. | |
typedef HistIterator< const T > | const_iterator |
Custom constant iterator over a histogram. | |
Public Member Functions | |
Histogram (std::vector< int > numPoints, std::vector< double > lower, std::vector< double > upper, std::vector< bool > isPeriodic) | |
Constructor. More... | |
iterator | begin () |
Return iterator at first bin of histogram. More... | |
iterator | end () |
Return iterator after last valid bin. More... | |
std::vector< T >::const_iterator | begin () const |
Return const iterator at first bin of histogram. More... | |
std::vector< T >::const_iterator | end () const |
Return const iterator after last valid bin. More... | |
![]() | |
size_t | GetDimension () const |
Get the dimension. More... | |
const std::vector< int > & | GetNumPoints () const |
Get the number of points for all dimensions. More... | |
int | GetNumPoints (size_t dim) const |
Get the number of points for a specific dimension. More... | |
const std::vector< double > & | GetLower () const |
Return the lower edges of the Grid. More... | |
double | GetLower (size_t dim) const |
Get the lower edge for a specific dimension. More... | |
const std::vector< double > & | GetUpper () const |
Return the upper edges of the Grid. More... | |
double | GetUpper (size_t dim) const |
Get the upper edge for a specific dimension. More... | |
const std::vector< bool > & | GetPeriodic () const |
Return the periodicity of the Grid. More... | |
bool | GetPeriodic (size_t dim) const |
Get the periodicity in a specific dimension. More... | |
size_t | size () const |
Get the size of the internal storage vector. More... | |
T * | data () |
Get pointer to the internal data storage vector. More... | |
T const * | data () const |
Get pointer to const of the internal data storage vector. More... | |
std::vector< int > | GetIndices (const std::vector< double > &x) const |
Return the Grid indices for a given point. More... | |
double | GetInterpolated (const std::vector< double > &x) |
Return linear interpolation on a coordinate. More... | |
int | GetIndex (double x) const |
Return the Grid index for a one-dimensional grid. More... | |
std::vector< double > | GetCoordinates (const std::vector< int > &indices) |
Return coordinates of the grid center points. More... | |
double | GetCoordinate (int index) |
Return center point of 1d-grid. More... | |
const T & | at (const std::vector< int > &indices) const |
Access Grid element read-only. More... | |
T & | at (const std::vector< int > &indices) |
Access Grid element read/write. More... | |
template<typename R > | |
const T & | at (std::initializer_list< R > &&x) const |
Const access of Grid element via initializer list. More... | |
template<typename R > | |
T & | at (std::initializer_list< R > &&x) |
Access Grid element via initializer list. More... | |
const T & | at (int index) const |
Access 1d Grid by index, read-only. More... | |
T & | at (int index) |
Access 1d Grid by index, read-write. More... | |
const T & | at (const std::vector< double > &x) const |
Access Grid element pertaining to a specific point – read-only. More... | |
T & | at (const std::vector< double > &x) |
Access Grid element pertaining to a specific point – read/write. More... | |
const T & | at (double x) const |
Access 1d-Grid by point - read-only. More... | |
T & | at (double x) |
Access 1d-Grid by point - read-write. More... | |
const T & | operator[] (const std::vector< int > &indices) const |
Access Grid element per [] read-only. More... | |
T & | operator[] (const std::vector< int > &indices) |
Access Grid element per [] read-write. More... | |
template<typename R > | |
const T & | operator[] (std::initializer_list< R > &&x) const |
Const access of Grid element via initializer list. More... | |
template<typename R > | |
T & | operator[] (std::initializer_list< R > &&x) |
Access Grid element via initializer list. More... | |
const T & | operator[] (int index) const |
Access 1d-Grid per [] operator, read-only. More... | |
T & | operator[] (int index) |
Access 1d-Grid per [] operator, read-write. More... | |
const T & | operator[] (const std::vector< double > &x) const |
Access Grid element pertaining to a specific point per [] read-only. More... | |
T & | operator[] (const std::vector< double > &x) |
Access Grid element pertaining to a specific point per [] read-write. More... | |
const T & | operator[] (double x) const |
Access 1d-Grid via specific point, read-only. More... | |
T & | operator[] (double x) |
Access 1d-Grid via specific point, read-write. More... | |
Static Public Member Functions | |
static Histogram< T > * | BuildHistogram (const Json::Value &json) |
Set up the histogram. More... | |
static Histogram< T > * | BuildHistogram (const Json::Value &json, const std::string &path) |
Set up the histogram. More... | |
Private Member Functions | |
size_t | mapTo1d (const std::vector< int > &indices) const override |
Map d-dimensional indices to 1-d data vector. More... | |
Additional Inherited Members | |
![]() | |
std::vector< int > | wrapIndices (const std::vector< int > &indices) const |
Wrap the index around periodic boundaries. | |
GridBase (std::vector< int > numPoints, std::vector< double > lower, std::vector< double > upper, std::vector< bool > isPeriodic) | |
Constructor. More... | |
![]() | |
std::vector< T > | data_ |
Internal storage of the data. | |
size_t | dimension_ |
Dimension of the grid. | |
std::vector< int > | numPoints_ |
Number of points in each dimension. | |
std::pair< std::vector< double > , std::vector< double > > | edges_ |
Edges of the Grid in each dimension. | |
std::vector< bool > | isPeriodic_ |
Periodicity of the Grid. | |
Basic Histogram.
T | type of data to be stored in the histogram. |
A Histogram is a method to store data in SSAGES. It is used to discretize a continuous number, typically a collective variable, into number_points
bins. For each bin, an arbitrary type of data can be stored, specified via the template parameter T
.
The histogram can be of arbitrary dimension. For each dimension, the lower bound, the upper bound and the number of grid points need to be specified. Furthermore, the histogram can be defined as periodic or non-periodic in the respective dimension. By default, the histogram is non-periodic. The bins are indexed from 0 to number_points-1 following the standard C/C++ convention. In contrast to the Grid, a Histogram additionally includes an under- and an overflow bin in each non-periodic dimension. These can be accessed via the indices -1 an number_points
(see below).
The bin width Delta
is given by (upper - lower)/number_points. Thus, bin n
corresponds to the interval [lower + n*Delta, lower + (n+1)*Delta). Note that n follows the C/C++ convention, i.e. n = 0 for the first interval. The bin indices pertaining to a given point can be obtained via GetIndices().
In non-periodic dimensions, an overflow and an underflow interval exist. The underflow interval corresponds to the interval (-infinity, lower), i.e. all points below lower
. Similarly, the overflow interval corresponds to the interval [upper, infinity). The underflow grid point can be accessed via the index -1, the overflow grid point via the index number_points
.
Definition at line 64 of file Histogram.h.
|
inline |
Constructor.
numPoints | Number of grid points in each dimension. |
lower | Lower edges of the grid. |
upper | Upper edges of the grid. |
isPeriodic | Bools specifying the periodicity in the respective dimension. |
The dimension of the grid is determined by the size of the parameter vectors.
Definition at line 116 of file Histogram.h.
Referenced by SSAGES::Histogram< int >::BuildHistogram().
|
inline |
Return iterator at first bin of histogram.
The first bin is the bin that has the lowest allowed index in all dimensions, i.e. 0 in periodic and -1 in non-periodic dimensions.
Definition at line 549 of file Histogram.h.
Referenced by SSAGES::Basis::PrintBias(), and SSAGES::Basis::UpdateBias().
|
inline |
Return const iterator at first bin of histogram.
The first bin is the bin that has the lowest allowed index in all dimensions, i.e. 0 in periodic and -1 in non-periodic dimensions.
Definition at line 593 of file Histogram.h.
|
inlinestatic |
Set up the histogram.
json | JSON value containing all input information. |
This function builds a histogram from a JSON node. It will return a nullptr if an unknown error occured, but generally, it will throw a BuildException of failure.
Definition at line 141 of file Histogram.h.
Referenced by SSAGES::Histogram< int >::BuildHistogram().
|
inlinestatic |
Set up the histogram.
json | JSON Value containing all input information. |
path | Path for JSON path specification. |
This function builds a histogram from a JSON node. It will return a nullptr if an unknown error occured, but generally, it will throw a BuildException on failure.
Definition at line 156 of file Histogram.h.
|
inline |
Return iterator after last valid bin.
The last valid bin is the bin that has the highest allowed index in all dimensions, i.e. num_points - 1 in periodic and num_points in non-periodic dimensions.
Definition at line 571 of file Histogram.h.
|
inline |
Return const iterator after last valid bin.
The last valid bin is the bin that has the highest allowed index in all dimensions, i.e. num_points - 1 in periodic and num_points in non-periodic dimensions.
Definition at line 615 of file Histogram.h.
|
inlineoverrideprivatevirtual |
Map d-dimensional indices to 1-d data vector.
indices | Vector specifying the grid point. |
Map a set of indices to the index of the 1d data vector. Keep in mind, that the data includes underflow (index -1) and overflow (index numPoints) bins in periodic dimension.
Implements SSAGES::GridBase< T >.
Definition at line 76 of file Histogram.h.