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> >, sse_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> >, sse_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> >, sse_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 BLAZE_ALWAYS_INLINE sse_cfloat_t set( const complex<float>& value )
186 {
187 #if BLAZE_MIC_MODE
188  return _mm512_set_ps( value.imag(), value.real(), value.imag(), value.real(),
189  value.imag(), value.real(), value.imag(), value.real(),
190  value.imag(), value.real(), value.imag(), value.real(),
191  value.imag(), value.real(), value.imag(), value.real() );
192 #elif BLAZE_AVX_MODE
193  return _mm256_set_ps( value.imag(), value.real(), value.imag(), value.real(),
194  value.imag(), value.real(), value.imag(), value.real() );
195 #elif BLAZE_SSE_MODE
196  return _mm_set_ps( value.imag(), value.real(), value.imag(), value.real() );
197 #else
198  return value;
199 #endif
200  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
201 }
202 //*************************************************************************************************
203 
204 
205 //*************************************************************************************************
212 BLAZE_ALWAYS_INLINE sse_cdouble_t set( const complex<double>& value )
213 {
214 #if BLAZE_MIC_MODE
215  return _mm512_set_pd( value.imag(), value.real(), value.imag(), value.real(),
216  value.imag(), value.real(), value.imag(), value.real() );
217 #elif BLAZE_AVX_MODE
218  return _mm256_set_pd( value.imag(), value.real(), value.imag(), value.real() );
219 #elif BLAZE_SSE2_MODE
220  return _mm_set_pd( value.imag(), value.real() );
221 #else
222  return value;
223 #endif
224  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
225 }
226 //*************************************************************************************************
227 
228 } // namespace blaze
229 
230 #endif
Intrinsic type for 32-bit single precision complex values.
Header file for basic type definitions.
Header file for the IsIntegral type trait.
Header file for the And class template.
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.
Intrinsic type for 32-bit single precision floating point data values.
Intrinsic type for 64-bit double precision complex values.
Constraint on the data type.
Header file for the EnableIf class template.
Intrinsic type for 64-bit double precision floating point data values.
Header file for the basic intrinsic types.
Header file for run time assertion macros.
Header file for the HasSize type trait.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
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.