28 namespace GridContainer {
30 template<
typename... AxesTypes>
43 template<
typename... AxesTypes>
50 template <
typename Coord>
52 return coord * factors[factors.
size() - 2];
55 template <
typename Coord,
typename... RestCoords>
56 size_t calculateTotalIndex(
const std::vector<size_t>& factors, Coord coord, RestCoords... rest_coords) {
57 return coord * factors[factors.
size()-
sizeof...(RestCoords)-2] + calculateTotalIndex(factors, rest_coords...);
60 template<
typename... AxesTypes>
65 template <
typename Coord>
68 if (coord >= axes_sizes[axes_sizes.
size()-1]) {
70 << axes_names[axes_sizes.
size()-1] <<
" (size "
71 << axes_sizes[axes_sizes.
size()-1]
72 <<
") is out of bound";
76 template <
typename Coord,
typename... RestCoords>
79 if (coord >= axes_sizes[axes_sizes.
size()-
sizeof...(RestCoords)-1]) {
81 << axes_names[axes_sizes.
size()-
sizeof...(RestCoords)-1] <<
" (size "
82 << axes_sizes[axes_sizes.
size()-
sizeof...(RestCoords)-1]
83 <<
") is out of bound";
85 checkBounds(axes_names, axes_sizes, rest_coords...);
88 template<
typename... AxesTypes>
94 template<
typename... AxesTypes>
95 template <
typename Coord>
105 template<
typename... AxesTypes>
106 template <
typename Coord,
typename... RestCoords>
108 Coord coord, RestCoords... rest_coords)
const {
111 if (fixed_indices.
find(axis_index) != fixed_indices.
end()) {
113 <<
m_axes_names[axis_index] <<
" (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