Set.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_SET_H_
36 #define _BLAZE_MATH_INTRINSICS_SET_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 #include <blaze/util/Assert.h>
48 #include <blaze/util/EnableIf.h>
49 #include <blaze/util/mpl/And.h>
51 #include <blaze/util/Types.h>
54 
55 
56 namespace blaze {
57 
58 //=================================================================================================
59 //
60 // INTRINSIC SET FUNCTIONS
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
71 template< typename T > // Type of the integral value
72 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> >, simd_int16_t >::Type
73  set( T value )
74 {
75 #if BLAZE_AVX2_MODE
76  return _mm256_set1_epi16( value );
77 #elif BLAZE_SSE2_MODE
78  return _mm_set1_epi16( value );
79 #else
80  return value;
81 #endif
82 }
83 //*************************************************************************************************
84 
85 
86 //*************************************************************************************************
93 template< typename T > // Type of the integral value
94 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> >, simd_int32_t >::Type
95  set( T value )
96 {
97 #if BLAZE_MIC_MODE
98  return _mm512_set1_epi32( value );
99 #elif BLAZE_AVX2_MODE
100  return _mm256_set1_epi32( value );
101 #elif BLAZE_SSE2_MODE
102  return _mm_set1_epi32( value );
103 #else
104  return value;
105 #endif
106 }
107 //*************************************************************************************************
108 
109 
110 //*************************************************************************************************
117 template< typename T > // Type of the integral value
118 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> >, simd_int64_t >::Type
119  set( T value )
120 {
121 #if BLAZE_MIC_MODE
122  return _mm512_set1_epi64( value );
123 #elif BLAZE_AVX2_MODE
124  return _mm256_set1_epi64x( value );
125 #elif BLAZE_SSE2_MODE
126  return _mm_set1_epi64( value );
127 #else
128  return value;
129 #endif
130 }
131 //*************************************************************************************************
132 
133 
134 //*************************************************************************************************
142 {
143 #if BLAZE_MIC_MODE
144  return _mm512_set1_ps( value );
145 #elif BLAZE_AVX_MODE
146  return _mm256_set1_ps( value );
147 #elif BLAZE_SSE_MODE
148  return _mm_set1_ps( value );
149 #else
150  return value;
151 #endif
152 }
153 //*************************************************************************************************
154 
155 
156 //*************************************************************************************************
164 {
165 #if BLAZE_MIC_MODE
166  return _mm512_set1_pd( value );
167 #elif BLAZE_AVX_MODE
168  return _mm256_set1_pd( value );
169 #elif BLAZE_SSE2_MODE
170  return _mm_set1_pd( value );
171 #else
172  return value;
173 #endif
174 }
175 //*************************************************************************************************
176 
177 
178 //*************************************************************************************************
185 template< typename T > // Type of the integral value
186 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,2UL> >, simd_cint16_t >::Type
187  set( complex<T> value )
188 {
189 #if BLAZE_AVX2_MODE
190  return _mm256_set_epi16( value.imag(), value.real(), value.imag(), value.real(),
191  value.imag(), value.real(), value.imag(), value.real(),
192  value.imag(), value.real(), value.imag(), value.real(),
193  value.imag(), value.real(), value.imag(), value.real() );
194 #elif BLAZE_SSE2_MODE
195  return _mm_set_epi16( value.imag(), value.real(), value.imag(), value.real(),
196  value.imag(), value.real(), value.imag(), value.real() );
197 #else
198  return value;
199 #endif
200  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
201 }
202 //*************************************************************************************************
203 
204 
205 //*************************************************************************************************
212 template< typename T > // Type of the integral value
213 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,4UL> >, simd_cint32_t >::Type
214  set( complex<T> value )
215 {
216 #if BLAZE_MIC_MODE
217  return _mm512_set_epi32( value.imag(), value.real(), value.imag(), value.real(),
218  value.imag(), value.real(), value.imag(), value.real(),
219  value.imag(), value.real(), value.imag(), value.real(),
220  value.imag(), value.real(), value.imag(), value.real() );
221 #elif BLAZE_AVX2_MODE
222  return _mm256_set_epi32( value.imag(), value.real(), value.imag(), value.real(),
223  value.imag(), value.real(), value.imag(), value.real() );
224 #elif BLAZE_SSE2_MODE
225  return _mm_set_epi32( value.imag(), value.real(), value.imag(), value.real() );
226 #else
227  return value;
228 #endif
229  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
230 }
231 //*************************************************************************************************
232 
233 
234 //*************************************************************************************************
241 template< typename T > // Type of the integral value
242 BLAZE_ALWAYS_INLINE typename EnableIf< And< IsIntegral<T>, HasSize<T,8UL> >, simd_cint64_t >::Type
243  set( complex<T> value )
244 {
245 #if BLAZE_MIC_MODE
246  return _mm512_set_epi64( value.imag(), value.real(), value.imag(), value.real(),
247  value.imag(), value.real(), value.imag(), value.real() );
248 #elif BLAZE_AVX2_MODE
249  return _mm256_set_epi64( value.imag(), value.real(), value.imag(), value.real() );
250 #elif BLAZE_SSE2_MODE
251  return _mm_set_epi64( value.imag(), value.real() );
252 #else
253  return value;
254 #endif
255  BLAZE_STATIC_ASSERT( sizeof( complex<T> ) == 2UL*sizeof( T ) );
256 }
257 //*************************************************************************************************
258 
259 
260 //*************************************************************************************************
267 BLAZE_ALWAYS_INLINE simd_cfloat_t set( const complex<float>& value )
268 {
269 #if BLAZE_MIC_MODE
270  return _mm512_set_ps( value.imag(), value.real(), value.imag(), value.real(),
271  value.imag(), value.real(), value.imag(), value.real(),
272  value.imag(), value.real(), value.imag(), value.real(),
273  value.imag(), value.real(), value.imag(), value.real() );
274 #elif BLAZE_AVX_MODE
275  return _mm256_set_ps( value.imag(), value.real(), value.imag(), value.real(),
276  value.imag(), value.real(), value.imag(), value.real() );
277 #elif BLAZE_SSE_MODE
278  return _mm_set_ps( value.imag(), value.real(), value.imag(), value.real() );
279 #else
280  return value;
281 #endif
282  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
283 }
284 //*************************************************************************************************
285 
286 
287 //*************************************************************************************************
294 BLAZE_ALWAYS_INLINE simd_cdouble_t set( const complex<double>& value )
295 {
296 #if BLAZE_MIC_MODE
297  return _mm512_set_pd( value.imag(), value.real(), value.imag(), value.real(),
298  value.imag(), value.real(), value.imag(), value.real() );
299 #elif BLAZE_AVX_MODE
300  return _mm256_set_pd( value.imag(), value.real(), value.imag(), value.real() );
301 #elif BLAZE_SSE2_MODE
302  return _mm_set_pd( value.imag(), value.real() );
303 #else
304  return value;
305 #endif
306  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
307 }
308 //*************************************************************************************************
309 
310 } // namespace blaze
311 
312 #endif
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
Header file for basic type definitions.
Header file for the IsIntegral type trait.
Header file for the And class template.
Intrinsic type for 64-bit double precision floating point data values.
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
Compile time assertion.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the basic intrinsic types.
Intrinsic type for 32-bit single precision floating point data values.
Header file for run time assertion macros.
Header file for the HasSize type trait.
Intrinsic type for 64-bit double precision complex values.
Intrinsic type for 32-bit single precision complex values.
System settings for the SSE mode.
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
System settings for the inline keywords.