metadynamics
|
Helper Class to cacluate a one-dimensional index for a d-dimensional grid.
Public Member Functions | |
IndexGrid () | |
Constructs an index for one-dimensional grid of length 1. | |
IndexGrid (const std::vector< unsigned int > &lengths) | |
Constructs an index for a d-dimensional grid of given lengths. | |
void | setLengths (const std::vector< unsigned int > &lengths) |
Set the dimensions and lengths of the grid. | |
unsigned int | getIndex (const std::vector< unsigned int > &coords) |
Get a grid index for given coordinates. | |
void | getCoordinates (const unsigned int idx, std::vector< unsigned int > &coords) |
Get the coordinates for a given grid index. | |
unsigned int | getNumElements () |
Returns the total number of grid elements. | |
unsigned int | getLength (const unsigned int i) |
Returns the length of the grid in a given direction. | |
unsigned int | getDimension () |
Returns the dimensionsality of the grid. |
Private Attributes | |
std::vector< unsigned int > | m_lengths |
Stores the lengths in every direction. | |
std::vector< unsigned int > | m_factors |
Pre-calculated factors for converting between index and coordinates. |
IndexGrid | ( | const std::vector< unsigned int > & | lengths | ) |
Constructs an index for a d-dimensional grid of given lengths.
lengths | List of grid points in every direction |
void getCoordinates | ( | const unsigned int | idx, |
std::vector< unsigned int > & | coords | ||
) |
Get the coordinates for a given grid index.
idx | The grid index |
coords | The grid coordinates (output variable) |
unsigned int getIndex | ( | const std::vector< unsigned int > & | coords | ) |
Get a grid index for given coordinates.
coords | Coordinates of the grid point in d dimensions |
unsigned int getLength | ( | const unsigned int | i | ) |
Returns the length of the grid in a given direction.
i | Index of the direction |
void setLengths | ( | const std::vector< unsigned int > & | lengths | ) |
Set the dimensions and lengths of the grid.
lengths | List of grid points in every direction |