metadynamics
Public Member Functions | Private Attributes
IndexGrid Class Reference

Detailed Description

Helper Class to cacluate a one-dimensional index for a d-dimensional grid.

List of all members.

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.

Constructor & Destructor Documentation

IndexGrid ( const std::vector< unsigned int > &  lengths)

Constructs an index for a d-dimensional grid of given lengths.

Parameters:
lengthsList of grid points in every direction

Member Function Documentation

void getCoordinates ( const unsigned int  idx,
std::vector< unsigned int > &  coords 
)

Get the coordinates for a given grid index.

Parameters:
idxThe grid index
coordsThe grid coordinates (output variable)
unsigned int getIndex ( const std::vector< unsigned int > &  coords)

Get a grid index for given coordinates.

Parameters:
coordsCoordinates of the grid point in d dimensions
Returns:
The grid index
unsigned int getLength ( const unsigned int  i)

Returns the length of the grid in a given direction.

Parameters:
iIndex of the direction
void setLengths ( const std::vector< unsigned int > &  lengths)

Set the dimensions and lengths of the grid.

Parameters:
lengthsList of grid points in every direction

The documentation for this class was generated from the following files: