Alexandria  2.16
Please provide a description of the project.
GridIndexHelper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 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 
28 #include <vector>
29 #include <tuple>
30 #include "GridContainer/GridAxis.h"
32 
33 namespace Euclid {
34 namespace GridContainer {
35 
53 template<typename... AxesTypes>
55 
56 public:
57 
65  explicit GridIndexHelper(const std::tuple<GridAxis<AxesTypes>...>& axes_tuple);
66 
70 
72  virtual ~GridIndexHelper() = default;
73 
83  size_t axisIndex(size_t axis, size_t array_index) const;
84 
92  size_t totalIndex(decltype(std::declval<GridAxis<AxesTypes>>().size())... coords) const;
93 
103  size_t totalIndexChecked(decltype(std::declval<GridAxis<AxesTypes>>().size())... coords) const;
104 
106  template <typename Coord>
107  void checkAllFixedAreZero(const std::map<size_t, size_t>& fixed_indices, Coord coord) const;
108 
110  template <typename Coord, typename... RestCoords>
112  Coord coord, RestCoords... rest_coords) const;
113 
117 };
118 
128 template<typename... AxesTypes>
130  return GridIndexHelper<AxesTypes...>(axes_tuple);
131 }
132 
133 } // end of namespace GridContainer
134 } // end of namespace Euclid
135 
137 
138 #endif /* GRIDCONTAINER_GRIDINDEXHELPER_H */
139 
GridIndexHelper.icpp
Euclid::GridContainer::makeGridIndexHelper
GridIndexHelper< AxesTypes... > makeGridIndexHelper(const std::tuple< GridAxis< AxesTypes >... > &axes_tuple)
Definition: GridIndexHelper.h:129
Euclid::GridContainer::GridAxis
Provides information related with an axis of a GridContainer.
Definition: GridAxis.h:49
Euclid::GridContainer::GridIndexHelper::operator=
GridIndexHelper & operator=(GridIndexHelper< AxesTypes... > &&)=default
GridAxis.h
std::vector< size_t >
Euclid::GridContainer::GridIndexHelper
Helper class for converting multi-dimensional grid coordinates to the index of a long data array and ...
Definition: GridIndexHelper.h:54
Euclid::GridContainer::GridIndexHelper::totalIndex
size_t totalIndex(decltype(std::declval< GridAxis< AxesTypes >>().size())... coords) const
std::tuple
Euclid::GridContainer::GridIndexHelper::checkAllFixedAreZero
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.
Euclid::GridContainer::GridIndexHelper::m_axes_names
std::vector< std::string > m_axes_names
Definition: GridIndexHelper.h:116
Euclid::GridContainer::GridIndexHelper::m_axes_sizes
std::vector< size_t > m_axes_sizes
Definition: GridIndexHelper.h:114
Euclid::GridContainer::GridIndexHelper::totalIndexChecked
size_t totalIndexChecked(decltype(std::declval< GridAxis< AxesTypes >>().size())... coords) const
Euclid::GridContainer::GridIndexHelper::checkAllFixedAreZero
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.
Euclid::GridContainer::GridIndexHelper::GridIndexHelper
GridIndexHelper(const std::tuple< GridAxis< AxesTypes >... > &axes_tuple)
std::map< size_t, size_t >
Euclid::GridContainer::GridIndexHelper::~GridIndexHelper
virtual ~GridIndexHelper()=default
Default destructor.
Euclid::GridContainer::GridIndexHelper::axisIndex
size_t axisIndex(size_t axis, size_t array_index) const
GridConstructionHelper.h
Euclid::GridContainer::GridIndexHelper::GridIndexHelper
GridIndexHelper(GridIndexHelper< AxesTypes... > &&)=default
Default move constructor and assignment operator.
Euclid
Definition: InstOrRefHolder.h:29
std::declval
T declval(T... args)
Euclid::GridContainer::GridIndexHelper::m_axes_index_factors
std::vector< size_t > m_axes_index_factors
Definition: GridIndexHelper.h:115