astrotypes  0.0
ReducedRankSlice.cpp
Go to the documentation of this file.
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2018 PulsarSearchSoft
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "ReducedRankSlice.h"
25 
26 
27 namespace pss {
28 namespace astrotypes {
29 
30 template<typename SliceType, typename ExcludedDim, std::size_t RankT, typename Dimension, typename... Dimensions>
31 struct has_exact_dimensions<multiarray::ReducedRankSlice<SliceType, ExcludedDim, RankT>, Dimension, Dimensions...>
32  : public std::is_same<typename multiarray::ReducedRankSlice<SliceType, ExcludedDim, RankT>::DimensionTuple, std::tuple<Dimension, Dimensions...>>::type
33 {
34 };
35 
36 template<typename SliceType, typename ExcludedDim, std::size_t RankT, typename Dimension, typename... Dimensions, template<typename> class SliceMixin>
37 struct has_exact_dimensions<SliceMixin<multiarray::ReducedRankSlice<SliceType, ExcludedDim, RankT>>, Dimension, Dimensions...>
38  : public has_exact_dimensions<multiarray::ReducedRankSlice<SliceType, ExcludedDim, RankT>, Dimension, Dimensions...>::type
39 {
40 };
41 
42 namespace multiarray {
43 
44 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
45 template<typename Dim>
46 typename std::enable_if<std::is_same<Dim, ExcludedDim>::value, std::size_t>::type
48 {
49  return 1;
50 }
51 
52 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
53 template<typename Dim>
54 typename std::enable_if<!std::is_same<Dim, ExcludedDim>::value
57 {
58  static_assert(RankT == 0, "not yet implemented");
59  return static_cast<BaseT&>(*this)[dimension];
60 }
61 
62 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
63 template<typename Dim>
64 typename std::enable_if<!std::is_same<Dim, ExcludedDim>::value
67 {
68  static_assert(RankT == 0, "not yet implemented");
69  return static_cast<BaseT const&>(*this)[dimension];
70 }
71 
72 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
74 {
75  static_assert(RankT == 0, "not yet implemented");
76  return BaseT::impl_begin();
77 }
78 
79 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
81 {
82  static_assert(RankT == 0, "not yet implemented");
83  return BaseT::impl_begin();
84 }
85 
86 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
88 {
89  static_assert(RankT == 0, "not yet implemented");
90  return BaseT::impl_cbegin();
91 }
92 
93 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
95 {
96  static_assert(RankT == 0, "not yet implemented");
97  return BaseT::impl_end();
98 }
99 
100 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
102 {
103  static_assert(RankT == 0, "not yet implemented");
104  return BaseT::impl_end();
105 }
106 
107 template<typename SliceType, typename ExcludedDim, std::size_t RankT>
109 {
110  static_assert(RankT == 0, "not yet implemented");
111  return BaseT::impl_cend();
112 }
113 
115 template<typename SliceType, typename ExcludedDim>
116 template<typename Dim>
117 typename std::enable_if<!has_type<typename ReducedRankSlice<SliceType, ExcludedDim, 1>::ExcludeTuple, Dim>::value
120 {
121  return *static_cast<BaseT&>(*this)[dimension].begin();
122 }
123 
124 template<typename SliceType, typename ExcludedDim>
125 template<typename Dim>
126 typename std::enable_if<!has_type<typename ReducedRankSlice<SliceType, ExcludedDim, 1>::ExcludeTuple, Dim>::value
129 {
130  return *static_cast<BaseT const&>(*this)[dimension].begin();
131 }
132 
133 template<typename SliceType, typename ExcludedDim>
135 {
136  return BaseT::impl_begin();
137 }
138 
139 template<typename SliceType, typename ExcludedDim>
141 {
142  return BaseT::impl_begin();
143 }
144 
145 template<typename SliceType, typename ExcludedDim>
147 {
148  return BaseT::impl_cbegin();
149 }
150 
151 template<typename SliceType, typename ExcludedDim>
153 {
154  return BaseT::impl_end();
155 }
156 
157 template<typename SliceType, typename ExcludedDim>
159 {
160  return BaseT::impl_end();
161 }
162 
163 template<typename SliceType, typename ExcludedDim>
165 {
166  return BaseT::impl_cend();
167 }
168 
169 template<typename SliceType, typename ExcludedDim>
170 template<typename Dim>
171 typename std::enable_if<std::is_same<Dim, ExcludedDim>::value, std::size_t>::type
173 {
174  return 1;
175 }
176 
177 } // namespace multiarray
178 } // namespace astrotypes
179 } // namespace pss
A tagged dimensionIndex variable.
SliceIteratorHelper< ReducedRankSlice, typename SliceType::iterator >::type iterator
iterator begin()
iterator pointing to the first element in the slice
std::enable_if<!std::is_same< Dim, ExcludedDim >::value, ReducedRankSlice< typename SliceMixinRemover< typename SliceType::template OperatorSliceType< Dim >::type >::type, ExcludedDim > >::type operator[](DimensionIndex< Dim >)
return true if the Dimensions provided match exactly those of the structure T (including order) ...
Definition: TypeTraits.h:107
static std::enable_if< std::is_same< Dim, ExcludedDim >::value, std::size_t >::type dimension()
the width of the slice in this dimesnion has been reduced to 1
iterator end()
iterator pointing to just after the last element
SliceIteratorHelper< ReducedRankSlice, typename SliceType::const_iterator >::type const_iterator