Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Helper class for converting multi-dimensional grid coordinates to the index of a long data array and vice versa. More...
#include <GridIndexHelper.h>
Public Member Functions | |
GridIndexHelper (const std::tuple< GridAxis< AxesTypes >... > &axes_tuple) | |
GridIndexHelper (GridIndexHelper< AxesTypes... > &&)=default | |
Default move constructor and assignment operator. | |
GridIndexHelper & | operator= (GridIndexHelper< AxesTypes... > &&)=default |
virtual | ~GridIndexHelper ()=default |
Default destructor. | |
size_t | axisIndex (size_t axis, size_t array_index) const |
size_t | totalIndex (decltype(std::declval< GridAxis< AxesTypes > >().size())... coords) const |
size_t | totalIndexChecked (decltype(std::declval< GridAxis< AxesTypes > >().size())... coords) const |
template<typename Coord > | |
void | checkAllFixedAreZero (const std::map< size_t, size_t > &fixed_indices, Coord coord) const |
Checks if any of the given coordinates is fixed and not zero. | |
template<typename Coord , typename... RestCoords> | |
void | checkAllFixedAreZero (const std::map< size_t, size_t > &fixed_indices, Coord coord, RestCoords... rest_coords) const |
Checks if any of the given coordinates is fixed and not zero. | |
Public Attributes | |
std::vector< size_t > | m_axes_sizes |
std::vector< size_t > | m_axes_index_factors |
std::vector< std::string > | m_axes_names |
Helper class for converting multi-dimensional grid coordinates to the index of a long data array and vice versa.
The assumption for the mapping is that the first axis is assumed to vary the fastest and the last the slowest. All indices and coordinates are zero based (start from zero). This class exists mainly to be used internally for the GridContainer iterator operations, but it is considered part of the public interface of the GridContainer module and can be used by any class which wants to perform such conversions. Use of this class in such cases is recommended for performance reasons.
AxesTypes | The types of the GridContainer axes |
Definition at line 54 of file GridIndexHelper.h.
|
explicit |
Constructs a new GridIndexHelper instance for making conversions for a GridContainer with the given axes. For avoiding the long template syntax consider using the makeGridIndexHelper() factory method instead.
axes_tuple | The information about the axes of the GridContainer |
|
default |
Default move constructor and assignment operator.
|
virtualdefault |
Default destructor.
size_t Euclid::GridContainer::GridIndexHelper< AxesTypes >::axisIndex | ( | size_t | axis, |
size_t | array_index | ||
) | const |
Returns the coordinate of the GridContainer axis with the given index which corresponds to the given index of a one dimensional array containing all the GridContainer elements.
axis | The axis to get the index for |
array_index | The index of the one dimensional array |
void Euclid::GridContainer::GridIndexHelper< AxesTypes >::checkAllFixedAreZero | ( | const std::map< size_t, size_t > & | fixed_indices, |
Coord | coord | ||
) | const |
Checks if any of the given coordinates is fixed and not zero.
void Euclid::GridContainer::GridIndexHelper< AxesTypes >::checkAllFixedAreZero | ( | const std::map< size_t, size_t > & | fixed_indices, |
Coord | coord, | ||
RestCoords... | rest_coords | ||
) | const |
Checks if any of the given coordinates is fixed and not zero.
|
default |
size_t Euclid::GridContainer::GridIndexHelper< AxesTypes >::totalIndex | ( | decltype(std::declval< GridAxis< AxesTypes > >().size())... | coords | ) | const |
Returns the index of a one dimensional array which corresponds to the given GridContainer coordinates. This method does not perform any bound checks.
coords | The GridContainer coordinates |
size_t Euclid::GridContainer::GridIndexHelper< AxesTypes >::totalIndexChecked | ( | decltype(std::declval< GridAxis< AxesTypes > >().size())... | coords | ) | const |
Returns the index of a one dimensional array which corresponds to the given GridContainer coordinates. This method performs bound checks.
coords | The GridContainer coordinates |
Elements::Exception | if any coordinate is out of bound |
std::vector<size_t> Euclid::GridContainer::GridIndexHelper< AxesTypes >::m_axes_index_factors |
Definition at line 114 of file GridIndexHelper.h.
std::vector<std::string> Euclid::GridContainer::GridIndexHelper< AxesTypes >::m_axes_names |
Definition at line 115 of file GridIndexHelper.h.
std::vector<size_t> Euclid::GridContainer::GridIndexHelper< AxesTypes >::m_axes_sizes |
Definition at line 113 of file GridIndexHelper.h.