Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
GridIndexHelper.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012-2021 Euclid Science Ground Segment
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
25#ifndef GRIDCONTAINER_GRIDINDEXHELPER_H
26#define GRIDCONTAINER_GRIDINDEXHELPER_H
27
30#include <tuple>
31#include <vector>
32
33namespace Euclid {
34namespace GridContainer {
35
53template <typename... AxesTypes>
55
56public:
64 explicit GridIndexHelper(const std::tuple<GridAxis<AxesTypes>...>& axes_tuple);
65
69
71 virtual ~GridIndexHelper() = default;
72
82 size_t axisIndex(size_t axis, size_t array_index) const;
83
91 size_t totalIndex(decltype(std::declval<GridAxis<AxesTypes>>().size())... coords) const;
92
102 size_t totalIndexChecked(decltype(std::declval<GridAxis<AxesTypes>>().size())... coords) const;
103
105 template <typename Coord>
106 void checkAllFixedAreZero(const std::map<size_t, size_t>& fixed_indices, Coord coord) const;
107
109 template <typename Coord, typename... RestCoords>
110 void checkAllFixedAreZero(const std::map<size_t, size_t>& fixed_indices, Coord coord,
111 RestCoords... rest_coords) const;
112
116};
117
127template <typename... AxesTypes>
129 return GridIndexHelper<AxesTypes...>(axes_tuple);
130}
131
132} // end of namespace GridContainer
133} // end of namespace Euclid
134
136
137#endif /* GRIDCONTAINER_GRIDINDEXHELPER_H */
Provides information related with an axis of a GridContainer.
Definition GridAxis.h:49
Helper class for converting multi-dimensional grid coordinates to the index of a long data array and ...
GridIndexHelper & operator=(GridIndexHelper< AxesTypes... > &&)=default
GridIndexHelper(GridIndexHelper< AxesTypes... > &&)=default
Default move constructor and assignment operator.
size_t axisIndex(size_t axis, size_t array_index) const
GridIndexHelper(const std::tuple< GridAxis< AxesTypes >... > &axes_tuple)
std::vector< std::string > m_axes_names
size_t totalIndex(decltype(std::declval< GridAxis< AxesTypes > >().size())... coords) const
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.
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.
virtual ~GridIndexHelper()=default
Default destructor.
size_t totalIndexChecked(decltype(std::declval< GridAxis< AxesTypes > >().size())... coords) const
T declval(T... args)
GridIndexHelper< AxesTypes... > makeGridIndexHelper(const std::tuple< GridAxis< AxesTypes >... > &axes_tuple)