Subtraction.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SIMD_SUBTRACTION_H_
36 #define _BLAZE_MATH_SIMD_SUBTRACTION_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // 8-BIT INTEGRAL SIMD TYPES
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
66 template< typename T > // Type of both operands
67 BLAZE_ALWAYS_INLINE const T
68  operator-( const SIMDi8<T>& a, const SIMDi8<T>& b ) noexcept
69 #if BLAZE_AVX2_MODE
70 {
71  return _mm256_sub_epi8( (~a).value, (~b).value );
72 }
73 #elif BLAZE_SSE2_MODE
74 {
75  return _mm_sub_epi8( (~a).value, (~b).value );
76 }
77 #else
78 = delete;
79 #endif
80 //*************************************************************************************************
81 
82 
83 //*************************************************************************************************
93 template< typename T1 // Type of the left-hand side operand
94  , typename T2 > // Type of the right-hand side operand
95 BLAZE_ALWAYS_INLINE const SIMDuint8
96  operator-( const SIMDi8<T1>& a, const SIMDi8<T2>& b ) noexcept
97 #if BLAZE_AVX2_MODE
98 {
99  return _mm256_sub_epi8( (~a).value, (~b).value );
100 }
101 #elif BLAZE_SSE2_MODE
102 {
103  return _mm_sub_epi8( (~a).value, (~b).value );
104 }
105 #else
106 = delete;
107 #endif
108 //*************************************************************************************************
109 
110 
111 //*************************************************************************************************
121 template< typename T > // Type of both operands
122 BLAZE_ALWAYS_INLINE const T
123  operator-( const SIMDci8<T>& a, const SIMDci8<T>& b ) noexcept
124 #if BLAZE_AVX2_MODE
125 {
126  return _mm256_sub_epi8( (~a).value, (~b).value );
127 }
128 #elif BLAZE_SSE2_MODE
129 {
130  return _mm_sub_epi8( (~a).value, (~b).value );
131 }
132 #else
133 = delete;
134 #endif
135 //*************************************************************************************************
136 
137 
138 
139 
140 //=================================================================================================
141 //
142 // 16-BIT INTEGRAL SIMD TYPES
143 //
144 //=================================================================================================
145 
146 //*************************************************************************************************
156 template< typename T > // Type of both operands
157 BLAZE_ALWAYS_INLINE const T
158  operator-( const SIMDi16<T>& a, const SIMDi16<T>& b ) noexcept
159 #if BLAZE_AVX2_MODE
160 {
161  return _mm256_sub_epi16( (~a).value, (~b).value );
162 }
163 #elif BLAZE_SSE2_MODE
164 {
165  return _mm_sub_epi16( (~a).value, (~b).value );
166 }
167 #else
168 = delete;
169 #endif
170 //*************************************************************************************************
171 
172 
173 //*************************************************************************************************
183 template< typename T1 // Type of the left-hand side operand
184  , typename T2 > // Type of the right-hand side operand
185 BLAZE_ALWAYS_INLINE const SIMDuint16
186  operator-( const SIMDi16<T1>& a, const SIMDi16<T2>& b ) noexcept
187 #if BLAZE_AVX2_MODE
188 {
189  return _mm256_sub_epi16( (~a).value, (~b).value );
190 }
191 #elif BLAZE_SSE2_MODE
192 {
193  return _mm_sub_epi16( (~a).value, (~b).value );
194 }
195 #else
196 = delete;
197 #endif
198 //*************************************************************************************************
199 
200 
201 //*************************************************************************************************
211 template< typename T > // Type of both operands
212 BLAZE_ALWAYS_INLINE const T
213  operator-( const SIMDci16<T>& a, const SIMDci16<T>& b ) noexcept
214 #if BLAZE_AVX2_MODE
215 {
216  return _mm256_sub_epi16( (~a).value, (~b).value );
217 }
218 #elif BLAZE_SSE2_MODE
219 {
220  return _mm_sub_epi16( (~a).value, (~b).value );
221 }
222 #else
223 = delete;
224 #endif
225 //*************************************************************************************************
226 
227 
228 
229 
230 //=================================================================================================
231 //
232 // 32-BIT INTEGRAL SIMD TYPES
233 //
234 //=================================================================================================
235 
236 //*************************************************************************************************
246 template< typename T > // Type of both operands
247 BLAZE_ALWAYS_INLINE const T
248  operator-( const SIMDi32<T>& a, const SIMDi32<T>& b ) noexcept
249 #if BLAZE_MIC_MODE
250 {
251  return _mm512_sub_epi32( (~a).value, (~b).value );
252 }
253 #elif BLAZE_AVX2_MODE
254 {
255  return _mm256_sub_epi32( (~a).value, (~b).value );
256 }
257 #elif BLAZE_SSE2_MODE
258 {
259  return _mm_sub_epi32( (~a).value, (~b).value );
260 }
261 #else
262 = delete;
263 #endif
264 //*************************************************************************************************
265 
266 
267 //*************************************************************************************************
277 template< typename T1 // Type of the left-hand side operand
278  , typename T2 > // Type of the right-hand side operand
279 BLAZE_ALWAYS_INLINE const SIMDuint32
280  operator-( const SIMDi32<T1>& a, const SIMDi32<T2>& b ) noexcept
281 #if BLAZE_MIC_MODE
282 {
283  return _mm512_sub_epi32( (~a).value, (~b).value );
284 }
285 #elif BLAZE_AVX2_MODE
286 {
287  return _mm256_sub_epi32( (~a).value, (~b).value );
288 }
289 #elif BLAZE_SSE2_MODE
290 {
291  return _mm_sub_epi32( (~a).value, (~b).value );
292 }
293 #else
294 = delete;
295 #endif
296 //*************************************************************************************************
297 
298 
299 //*************************************************************************************************
309 template< typename T > // Type of both operands
310 BLAZE_ALWAYS_INLINE const T
311  operator-( const SIMDci32<T>& a, const SIMDci32<T>& b ) noexcept
312 #if BLAZE_MIC_MODE
313 {
314  return _mm512_sub_epi32( (~a).value, (~b).value );
315 }
316 #elif BLAZE_AVX2_MODE
317 {
318  return _mm256_sub_epi32( (~a).value, (~b).value );
319 }
320 #elif BLAZE_SSE2_MODE
321 {
322  return _mm_sub_epi32( (~a).value, (~b).value );
323 }
324 #else
325 = delete;
326 #endif
327 //*************************************************************************************************
328 
329 
330 
331 
332 //=================================================================================================
333 //
334 // 64-BIT INTEGRAL SIMD TYPES
335 //
336 //=================================================================================================
337 
338 //*************************************************************************************************
348 template< typename T > // Type of both operands
349 BLAZE_ALWAYS_INLINE const T
350  operator-( const SIMDi64<T>& a, const SIMDi64<T>& b ) noexcept
351 #if BLAZE_MIC_MODE
352 {
353  return _mm512_sub_epi64( (~a).value, (~b).value );
354 }
355 #elif BLAZE_AVX2_MODE
356 {
357  return _mm256_sub_epi64( (~a).value, (~b).value );
358 }
359 #elif BLAZE_SSE2_MODE
360 {
361  return _mm_sub_epi64( (~a).value, (~b).value );
362 }
363 #else
364 = delete;
365 #endif
366 //*************************************************************************************************
367 
368 
369 //*************************************************************************************************
379 template< typename T1 // Type of the left-hand side operand
380  , typename T2 > // Type of the right-hand side operand
381 BLAZE_ALWAYS_INLINE const SIMDuint64
382  operator-( const SIMDi64<T1>& a, const SIMDi64<T2>& b ) noexcept
383 #if BLAZE_MIC_MODE
384 {
385  return _mm512_sub_epi64( (~a).value, (~b).value );
386 }
387 #elif BLAZE_AVX2_MODE
388 {
389  return _mm256_sub_epi64( (~a).value, (~b).value );
390 }
391 #elif BLAZE_SSE2_MODE
392 {
393  return _mm_sub_epi64( (~a).value, (~b).value );
394 }
395 #else
396 = delete;
397 #endif
398 //*************************************************************************************************
399 
400 
401 //*************************************************************************************************
411 template< typename T > // Type of both operands
412 BLAZE_ALWAYS_INLINE const T
413  operator-( const SIMDci64<T>& a, const SIMDci64<T>& b ) noexcept
414 #if BLAZE_MIC_MODE
415 {
416  return _mm512_sub_epi64( (~a).value, (~b).value );
417 }
418 #elif BLAZE_AVX2_MODE
419 {
420  return _mm256_sub_epi64( (~a).value, (~b).value );
421 }
422 #elif BLAZE_SSE2_MODE
423 {
424  return _mm_sub_epi64( (~a).value, (~b).value );
425 }
426 #else
427 = delete;
428 #endif
429 //*************************************************************************************************
430 
431 
432 
433 
434 //=================================================================================================
435 //
436 // 32-BIT FLOATING POINT SIMD TYPES
437 //
438 //=================================================================================================
439 
440 //*************************************************************************************************
450 template< typename T1 // Type of the left-hand side operand
451  , typename T2 > // Type of the right-hand side operand
452 BLAZE_ALWAYS_INLINE const SIMDfloat
453  operator-( const SIMDf32<T1>& a, const SIMDf32<T2>& b ) noexcept
454 #if BLAZE_MIC_MODE
455 {
456  return _mm512_sub_ps( (~a).eval().value, (~b).eval().value );
457 }
458 #elif BLAZE_AVX_MODE
459 {
460  return _mm256_sub_ps( (~a).eval().value, (~b).eval().value );
461 }
462 #elif BLAZE_SSE_MODE
463 {
464  return _mm_sub_ps( (~a).eval().value, (~b).eval().value );
465 }
466 #else
467 = delete;
468 #endif
469 //*************************************************************************************************
470 
471 
472 //*************************************************************************************************
482 BLAZE_ALWAYS_INLINE const SIMDcfloat
483  operator-( const SIMDcfloat& a, const SIMDcfloat& b ) noexcept
484 #if BLAZE_MIC_MODE
485 {
486  return _mm512_sub_ps( a.value, b.value );
487 }
488 #elif BLAZE_AVX_MODE
489 {
490  return _mm256_sub_ps( a.value, b.value );
491 }
492 #elif BLAZE_SSE_MODE
493 {
494  return _mm_sub_ps( a.value, b.value );
495 }
496 #else
497 = delete;
498 #endif
499 //*************************************************************************************************
500 
501 
502 
503 
504 //=================================================================================================
505 //
506 // 64-BIT FLOATING POINT SIMD TYPES
507 //
508 //=================================================================================================
509 
510 //*************************************************************************************************
520 template< typename T1 // Type of the left-hand side operand
521  , typename T2 > // Type of the right-hand side operand
522 BLAZE_ALWAYS_INLINE const SIMDdouble
523  operator-( const SIMDf64<T1>& a, const SIMDf64<T2>& b ) noexcept
524 #if BLAZE_MIC_MODE
525 {
526  return _mm512_sub_pd( (~a).eval().value, (~b).eval().value );
527 }
528 #elif BLAZE_AVX_MODE
529 {
530  return _mm256_sub_pd( (~a).eval().value, (~b).eval().value );
531 }
532 #elif BLAZE_SSE2_MODE
533 {
534  return _mm_sub_pd( (~a).eval().value, (~b).eval().value );
535 }
536 #else
537 = delete;
538 #endif
539 //*************************************************************************************************
540 
541 
542 //*************************************************************************************************
552 BLAZE_ALWAYS_INLINE const SIMDcdouble
553  operator-( const SIMDcdouble& a, const SIMDcdouble& b ) noexcept
554 #if BLAZE_MIC_MODE
555 {
556  return _mm512_sub_pd( a.value, b.value );
557 }
558 #elif BLAZE_AVX_MODE
559 {
560  return _mm256_sub_pd( a.value, b.value );
561 }
562 #elif BLAZE_SSE2_MODE
563 {
564  return _mm_sub_pd( a.value, b.value );
565 }
566 #else
567 = delete;
568 #endif
569 //*************************************************************************************************
570 
571 } // namespace blaze
572 
573 #endif
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the basic SIMD types.
const DMatEvalExpr< MT, SO > eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:705
System settings for the SSE mode.
System settings for the inline keywords.