Blaze 3.9
Add.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_FUNCTORS_ADD_H_
36#define _BLAZE_MATH_FUNCTORS_ADD_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
45#include <blaze/math/simd/Add.h>
68#include <blaze/system/Inline.h>
70
71
72namespace blaze {
73
74//=================================================================================================
75//
76// CLASS DEFINITION
77//
78//=================================================================================================
79
80//*************************************************************************************************
84struct Add
85{
86 //**********************************************************************************************
93 template< typename T1, typename T2 >
94 BLAZE_ALWAYS_INLINE BLAZE_DEVICE_CALLABLE decltype(auto) operator()( T1&& a, T2&& b ) const
95 {
96 return std::forward<T1>( a ) + std::forward<T2>( b );
97 }
98 //**********************************************************************************************
99
100 //**********************************************************************************************
105 template< typename T1, typename T2 >
106 static constexpr bool simdEnabled() { return HasSIMDAdd_v<T1,T2>; }
107 //**********************************************************************************************
108
109 //**********************************************************************************************
114 static constexpr bool paddingEnabled() { return true; }
115 //**********************************************************************************************
116
117 //**********************************************************************************************
124 template< typename T1, typename T2 >
125 BLAZE_ALWAYS_INLINE decltype(auto) load( const T1& a, const T2& b ) const
126 {
129 return a + b;
130 }
131 //**********************************************************************************************
132};
133//*************************************************************************************************
134
135
136
137
138//=================================================================================================
139//
140// YIELDSUNIFORM SPECIALIZATIONS
141//
142//=================================================================================================
143
144//*************************************************************************************************
146template< typename T1, typename T2 >
147struct YieldsUniform<Add,T1,T2>
148 : public BoolConstant< IsUniform_v<T1> && IsUniform_v<T2> >
149{};
151//*************************************************************************************************
152
153
154
155
156//=================================================================================================
157//
158// YIELDSSYMMETRIC SPECIALIZATIONS
159//
160//=================================================================================================
161
162//*************************************************************************************************
164template< typename MT1, typename MT2 >
165struct YieldsSymmetric<Add,MT1,MT2>
166 : public BoolConstant< IsSymmetric_v<MT1> && IsSymmetric_v<MT2> >
167{};
169//*************************************************************************************************
170
171
172
173
174//=================================================================================================
175//
176// YIELDSHERMITIAN SPECIALIZATIONS
177//
178//=================================================================================================
179
180//*************************************************************************************************
182template< typename MT1, typename MT2 >
183struct YieldsHermitian<Add,MT1,MT2>
184 : public BoolConstant< IsHermitian_v<MT1> && IsHermitian_v<MT2> >
185{};
187//*************************************************************************************************
188
189
190
191
192//=================================================================================================
193//
194// YIELDSLOWER SPECIALIZATIONS
195//
196//=================================================================================================
197
198//*************************************************************************************************
200template< typename MT1, typename MT2 >
201struct YieldsLower<Add,MT1,MT2>
202 : public BoolConstant< IsLower_v<MT1> && IsLower_v<MT2> >
203{};
205//*************************************************************************************************
206
207
208
209
210//=================================================================================================
211//
212// YIELDSUNILOWER SPECIALIZATIONS
213//
214//=================================================================================================
215
216//*************************************************************************************************
218template< typename MT1, typename MT2 >
219struct YieldsUniLower<Add,MT1,MT2>
220 : public BoolConstant< ( IsUniLower_v<MT1> && IsStrictlyLower_v<MT2> ) ||
221 ( IsUniLower_v<MT2> && IsStrictlyLower_v<MT1> ) >
222{};
224//*************************************************************************************************
225
226
227
228
229//=================================================================================================
230//
231// YIELDSSTRICTLYLOWER SPECIALIZATIONS
232//
233//=================================================================================================
234
235//*************************************************************************************************
237template< typename MT1, typename MT2 >
238struct YieldsStrictlyLower<Add,MT1,MT2>
239 : public BoolConstant< IsStrictlyLower_v<MT1> && IsStrictlyLower_v<MT2> >
240{};
242//*************************************************************************************************
243
244
245
246
247//=================================================================================================
248//
249// YIELDSUPPER SPECIALIZATIONS
250//
251//=================================================================================================
252
253//*************************************************************************************************
255template< typename MT1, typename MT2 >
256struct YieldsUpper<Add,MT1,MT2>
257 : public BoolConstant< IsUpper_v<MT1> && IsUpper_v<MT2> >
258{};
260//*************************************************************************************************
261
262
263
264
265//=================================================================================================
266//
267// YIELDSUNIUPPER SPECIALIZATIONS
268//
269//=================================================================================================
270
271//*************************************************************************************************
273template< typename MT1, typename MT2 >
274struct YieldsUniUpper<Add,MT1,MT2>
275 : public BoolConstant< ( IsUniUpper_v<MT1> && IsStrictlyUpper_v<MT2> ) ||
276 ( IsUniUpper_v<MT2> && IsStrictlyUpper_v<MT1> ) >
277{};
279//*************************************************************************************************
280
281
282
283
284//=================================================================================================
285//
286// YIELDSSTRICTLYUPPER SPECIALIZATIONS
287//
288//=================================================================================================
289
290//*************************************************************************************************
292template< typename MT1, typename MT2 >
293struct YieldsStrictlyUpper<Add,MT1,MT2>
294 : public BoolConstant< IsStrictlyUpper_v<MT1> && IsStrictlyUpper_v<MT2> >
295{};
297//*************************************************************************************************
298
299
300
301
302//=================================================================================================
303//
304// YIELDSZERO SPECIALIZATIONS
305//
306//=================================================================================================
307
308//*************************************************************************************************
310template< typename T1, typename T2 >
311struct YieldsZero<Add,T1,T2>
312 : public BoolConstant< IsZero_v<T1> && IsZero_v<T2> >
313{};
315//*************************************************************************************************
316
317} // namespace blaze
318
319#endif
Header file for the HasSIMDAdd type trait.
Macro for CUDA compatibility.
Header file for the IntegralConstant class template.
Header file for the IsHermitian type trait.
Header file for the IsLower type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUniform type trait.
Header file for the IsUpper type trait.
Header file for the YieldsHermitian type trait.
Header file for the YieldsLower type trait.
Header file for the YieldsStrictlyLower type trait.
Header file for the YieldsStrictlyUpper type trait.
Header file for the YieldsSymmetric type trait.
Header file for the YieldsUniLower type trait.
Header file for the YieldsUniUpper type trait.
Header file for the YieldsUniform type trait.
Header file for the YieldsUpper type trait.
Header file for the YieldsZero type trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_SIMD_PACK(T)
Constraint on the data type.
Definition: SIMDPack.h:60
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
Header file for the SIMD addition functionality.
Generic wrapper for the addition operator.
Definition: Add.h:85
BLAZE_ALWAYS_INLINE decltype(auto) load(const T1 &a, const T2 &b) const
Returns the result of the addition operation for the given SIMD vectors.
Definition: Add.h:125
static constexpr bool simdEnabled()
Returns whether SIMD is enabled for the specified data types T1 and T2.
Definition: Add.h:106
static constexpr bool paddingEnabled()
Returns whether the operation supports padding, i.e. whether it can deal with zeros.
Definition: Add.h:114
System settings for the inline keywords.
Header file for the IsZero type trait.