Blaze  3.6
ReduceTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TRAITS_REDUCETRAIT_H_
36 #define _BLAZE_MATH_TRAITS_REDUCETRAIT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/math/Aliases.h>
45 #include <blaze/util/InvalidType.h>
46 #include <blaze/util/Types.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // CLASS DEFINITION
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
59 template< typename, typename, size_t... > struct ReduceTrait;
60 template< typename, typename, typename = void > struct TotalReduceTraitEval1;
61 template< typename, typename, typename = void > struct TotalReduceTraitEval2;
62 template< typename, typename, size_t, typename = void > struct PartialReduceTraitEval1;
63 template< typename, typename, size_t, typename = void > struct PartialReduceTraitEval2;
65 //*************************************************************************************************
66 
67 
68 //*************************************************************************************************
70 template< size_t RF, typename T, typename OP >
71 auto evalReduceTrait( T&, OP )
72  -> typename PartialReduceTraitEval1<T,OP,RF>::Type;
73 
74 template< typename T, typename OP >
75 auto evalReduceTrait( T&, OP )
76  -> typename TotalReduceTraitEval1<T,OP>::Type;
77 
78 template< size_t RF, typename T, typename OP >
79 auto evalReduceTrait( const T&, OP )
80  -> typename ReduceTrait<T,OP,RF>::Type;
81 
82 template< typename T, typename OP >
83 auto evalReduceTrait( const T&, OP )
84  -> typename ReduceTrait<T,OP>::Type;
85 
86 template< size_t RF, typename T, typename OP >
87 auto evalReduceTrait( const volatile T&, OP )
88  -> typename ReduceTrait<T,OP,RF>::Type;
89 
90 template< typename T, typename OP >
91 auto evalReduceTrait( const volatile T&, OP )
92  -> typename ReduceTrait<T,OP>::Type;
94 //*************************************************************************************************
95 
96 
97 //*************************************************************************************************
142 template< typename T // Type of the operand
143  , typename OP // Type of the reduction operation
144  , size_t... RF > // Reduction flag
146 {
147  public:
148  //**********************************************************************************************
150  using Type = decltype( evalReduceTrait<RF...>( std::declval<T&>(), std::declval<OP>() ) );
152  //**********************************************************************************************
153 };
154 //*************************************************************************************************
155 
156 
157 //*************************************************************************************************
170 template< typename T // Type of the operand
171  , typename OP // Type of the reduction operation
172  , size_t... RF > // Reduction flag
173 using ReduceTrait_t = typename ReduceTrait<T,OP,RF...>::Type;
174 //*************************************************************************************************
175 
176 
177 //*************************************************************************************************
182 template< typename T // Type of the operand
183  , typename OP // Type of the custom operation
184  , typename > // Restricting condition
185 struct TotalReduceTraitEval1
186 {
187  public:
188  //**********************************************************************************************
189  using Type = typename TotalReduceTraitEval2<T,OP>::Type;
190  //**********************************************************************************************
191 };
193 //*************************************************************************************************
194 
195 
196 //*************************************************************************************************
201 template< typename T // Type of the operand
202  , typename OP // Type of the custom operation
203  , typename > // Restricting condition
204 struct TotalReduceTraitEval2
205 {
206  public:
207  //**********************************************************************************************
208  using Type = ElementType_t<T>;
209  //**********************************************************************************************
210 };
212 //*************************************************************************************************
213 
214 
215 //*************************************************************************************************
220 template< typename T // Type of the operand
221  , typename OP // Type of the custom operation
222  , size_t RF // Reduction flag
223  , typename > // Restricting condition
224 struct PartialReduceTraitEval1
225 {
226  public:
227  //**********************************************************************************************
228  using Type = typename PartialReduceTraitEval2<T,OP,RF>::Type;
229  //**********************************************************************************************
230 };
232 //*************************************************************************************************
233 
234 
235 //*************************************************************************************************
240 template< typename T // Type of the operand
241  , typename OP // Type of the custom operation
242  , size_t RF // Reduction flag
243  , typename > // Restricting condition
244 struct PartialReduceTraitEval2
245 {
246  public:
247  //**********************************************************************************************
248  using Type = INVALID_TYPE;
249  //**********************************************************************************************
250 };
252 //*************************************************************************************************
253 
254 } // namespace blaze
255 
256 #endif
Header file for auxiliary alias declarations.
Header file for basic type definitions.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.The ReduceTrait_t alias declaration pr...
Definition: ReduceTrait.h:173
Utility type for generic codes.
Base template for the ReduceTrait class.
Definition: ReduceTrait.h:145