Blaze 3.9
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>
48#include <blaze/util/Types.h>
49
50
51namespace blaze {
52
53//=================================================================================================
54//
55// CLASS DEFINITION
56//
57//=================================================================================================
58
59//*************************************************************************************************
61template< typename, typename, ReductionFlag... > struct ReduceTrait;
62template< typename, typename, typename = void > struct TotalReduceTraitEval1;
63template< typename, typename, typename = void > struct TotalReduceTraitEval2;
64template< typename, typename, ReductionFlag, typename = void > struct PartialReduceTraitEval1;
65template< typename, typename, ReductionFlag, typename = void > struct PartialReduceTraitEval2;
67//*************************************************************************************************
68
69
70//*************************************************************************************************
72template< ReductionFlag RF, typename T, typename OP >
73auto evalReduceTrait( const volatile T&, OP ) -> PartialReduceTraitEval1<T,OP,RF>;
74
75template< typename T, typename OP >
76auto evalReduceTrait( const volatile T&, OP ) -> TotalReduceTraitEval1<T,OP>;
78//*************************************************************************************************
79
80
81//*************************************************************************************************
125template< typename T // Type of the operand
126 , typename OP // Type of the reduction operation
127 , ReductionFlag... RF > // Reduction flag
129 : public decltype( evalReduceTrait<RF...>( std::declval<T&>(), std::declval<OP>() ) )
130{};
131//*************************************************************************************************
132
133
134//*************************************************************************************************
147template< typename T // Type of the operand
148 , typename OP // Type of the reduction operation
149 , ReductionFlag... RF > // Reduction flag
150using ReduceTrait_t = typename ReduceTrait<T,OP,RF...>::Type;
151//*************************************************************************************************
152
153
154//*************************************************************************************************
159template< typename T // Type of the operand
160 , typename OP // Type of the custom operation
161 , typename > // Restricting condition
162struct TotalReduceTraitEval1
163 : public TotalReduceTraitEval2<T,OP>
164{};
166//*************************************************************************************************
167
168
169//*************************************************************************************************
174template< typename T // Type of the operand
175 , typename OP // Type of the custom operation
176 , typename > // Restricting condition
177struct TotalReduceTraitEval2
178{};
180//*************************************************************************************************
181
182
183//*************************************************************************************************
188template< typename T // Type of the operand
189 , typename OP > // Type of the custom operation
190struct TotalReduceTraitEval2< T, OP, EnableIf_t< IsVector_v<T> || IsMatrix_v<T> > >
191{
192 public:
193 //**********************************************************************************************
194 using Type = decltype( std::declval<OP>()( std::declval< ElementType_t<T> >()
195 , std::declval< ElementType_t<T> >() ) );
196 //**********************************************************************************************
197};
199//*************************************************************************************************
200
201
202//*************************************************************************************************
207template< typename T // Type of the operand
208 , typename OP // Type of the custom operation
209 , ReductionFlag RF // Reduction flag
210 , typename > // Restricting condition
211struct PartialReduceTraitEval1
212 : public PartialReduceTraitEval2<T,OP,RF>
213{};
215//*************************************************************************************************
216
217
218//*************************************************************************************************
223template< typename T // Type of the operand
224 , typename OP // Type of the custom operation
225 , ReductionFlag RF // Reduction flag
226 , typename > // Restricting condition
227struct PartialReduceTraitEval2
228{};
230//*************************************************************************************************
231
232} // namespace blaze
233
234#endif
Header file for auxiliary alias declarations.
Header file for the IsMatrix type trait.
Header file for the IsVector type trait.
Header file for the reduction flags.
size_t ReductionFlag
Type of the reduction flags.
Definition: ReductionFlag.h:57
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.
Definition: ReduceTrait.h:150
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.
Definition: IsVector.h:125
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.
Definition: IsMatrix.h:124
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
Base template for the ReduceTrait class.
Definition: ReduceTrait.h:130
Header file for basic type definitions.