Blaze 3.9
Trunc.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_SIMD_TRUNC_H_
36#define _BLAZE_MATH_SIMD_TRUNC_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#if BLAZE_SLEEF_MODE
44# include <sleef.h>
45#endif
47#include <blaze/system/Inline.h>
49
50
51namespace blaze {
52
53//=================================================================================================
54//
55// 32-BIT FLOATING POINT SIMD TYPES
56//
57//=================================================================================================
58
59//*************************************************************************************************
69template< typename T > // Type of the operand
70BLAZE_ALWAYS_INLINE const SIMDfloat trunc( const SIMDf32<T>& a ) noexcept
71#if BLAZE_SVML_MODE
72# if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
73{
74 return _mm512_trunc_ps( (*a).eval().value );
75}
76# elif BLAZE_AVX_MODE
77{
78 return _mm256_trunc_ps( (*a).eval().value );
79}
80# elif BLAZE_SSE_MODE
81{
82 return _mm_trunc_ps( (*a).eval().value );
83}
84# endif
85#elif BLAZE_SLEEF_MODE
86# if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
87{
88 return Sleef_truncf16( (*a).eval().value );
89}
90# elif BLAZE_AVX_MODE
91{
92 return Sleef_truncf8( (*a).eval().value );
93}
94# elif BLAZE_SSE_MODE
95{
96 return Sleef_truncf4( (*a).eval().value );
97}
98# endif
99#elif BLAZE_XSIMD_MODE
100{
101 return SIMDfloat{ xsimd::trunc( xsimd::batch<float>{ (*a).eval().value } ).data };
102}
103#else
104= delete;
105#endif
106//*************************************************************************************************
107
108
109
110
111//=================================================================================================
112//
113// 64-BIT FLOATING POINT SIMD TYPES
114//
115//=================================================================================================
116
117//*************************************************************************************************
127template< typename T > // Type of the operand
128BLAZE_ALWAYS_INLINE const SIMDdouble trunc( const SIMDf64<T>& a ) noexcept
129#if BLAZE_SVML_MODE
130# if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
131{
132 return _mm512_trunc_pd( (*a).eval().value );
133}
134# elif BLAZE_AVX_MODE
135{
136 return _mm256_trunc_pd( (*a).eval().value );
137}
138# elif BLAZE_SSE_MODE
139{
140 return _mm_trunc_pd( (*a).eval().value );
141}
142# endif
143#elif BLAZE_SLEEF_MODE
144# if BLAZE_AVX512F_MODE || BLAZE_MIC_MODE
145{
146 return Sleef_truncd8( (*a).eval().value );
147}
148# elif BLAZE_AVX_MODE
149{
150 return Sleef_truncd4( (*a).eval().value );
151}
152# elif BLAZE_SSE_MODE
153{
154 return Sleef_truncd2( (*a).eval().value );
155}
156# endif
157#elif BLAZE_XSIMD_MODE
158{
159 return SIMDdouble{ xsimd::trunc( xsimd::batch<double>{ (*a).eval().value } ).data };
160}
161#else
162= delete;
163#endif
164//*************************************************************************************************
165
166} // namespace blaze
167
168#endif
Header file for the basic SIMD types.
SIMD type for 64-bit double precision floating point data values.
SIMD type for 32-bit single precision floating point data values.
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:182
BLAZE_ALWAYS_INLINE const SIMDdouble trunc(const SIMDf64< T > &a) noexcept=delete
Computes the nearest integer not greater in magnitude than the given value for a vector of double pre...
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
System settings for the inline keywords.
System settings for the SSE mode.