28 namespace GridContainer {
30 template <
typename... AxesTypes>
39 template <
typename... AxesTypes>
46 template <
typename Coord>
48 return coord * factors[factors.
size() - 2];
51 template <
typename Coord,
typename... RestCoords>
52 size_t calculateTotalIndex(
const std::vector<size_t>& factors, Coord coord, RestCoords... rest_coords) {
53 return coord * factors[factors.
size() -
sizeof...(RestCoords) - 2] + calculateTotalIndex(factors, rest_coords...);
56 template <
typename... AxesTypes>
61 template <
typename Coord>
63 if (coord >= axes_sizes[axes_sizes.
size() - 1]) {
64 throw Elements::Exception() <<
"Coordinate " << coord <<
" for axis " << axes_names[axes_sizes.
size() - 1] <<
" (size "
65 << axes_sizes[axes_sizes.
size() - 1] <<
") is out of bound";
69 template <
typename Coord,
typename... RestCoords>
71 RestCoords... rest_coords) {
72 if (coord >= axes_sizes[axes_sizes.
size() -
sizeof...(RestCoords) - 1]) {
74 << axes_names[axes_sizes.
size() -
sizeof...(RestCoords) - 1] <<
" (size "
75 << axes_sizes[axes_sizes.
size() -
sizeof...(RestCoords) - 1] <<
") is out of bound";
77 checkBounds(axes_names, axes_sizes, rest_coords...);
80 template <
typename... AxesTypes>
86 template <
typename... AxesTypes>
87 template <
typename Coord>
92 <<
" (size 1) is out of bound";
97 template <
typename... AxesTypes>
98 template <
typename Coord,
typename... RestCoords>
100 RestCoords... rest_coords)
const {
103 if (fixed_indices.
find(axis_index) != fixed_indices.
end()) {
105 <<
" (size 1) is out of bound";
std::vector< size_t > m_axes_index_factors
size_t totalIndex(decltype(std::declval< GridAxis< AxesTypes >>().size())...coords) const
GridIndexHelper(const std::tuple< GridAxis< AxesTypes >...> &axes_tuple)
std::vector< size_t > m_axes_sizes
static std::vector< std::string > createAxesNamesVector(const std::tuple< GridAxis< Axes >...> &axes, const TemplateLoopCounter< I > &)
Creates a vector which contains the names of the given axes.
Provides information related with an axis of a GridContainer.
std::vector< std::string > m_axes_names
static std::vector< size_t > createAxisIndexFactorVector(const std::tuple< GridAxis< Axes >...> &axes, const TemplateLoopCounter< I > &)
Creates a vector which contains the index factors of the given axes.
static std::vector< size_t > createAxesSizesVector(const std::tuple< GridAxis< Axes >...> &axes, const TemplateLoopCounter< I > &)
Creates a vector which contains the sizes of the given axes.
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.
size_t totalIndexChecked(decltype(std::declval< GridAxis< AxesTypes >>().size())...coords) const
size_t axisIndex(size_t axis, size_t array_index) const