10 #ifndef EIGEN_COMPLEX_SSE_H 11 #define EIGEN_COMPLEX_SSE_H 20 EIGEN_STRONG_INLINE Packet2cf() {}
21 EIGEN_STRONG_INLINE
explicit Packet2cf(
const __m128& a) : v(a) {}
27 #ifndef EIGEN_VECTORIZE_AVX 28 template<>
struct packet_traits<
std::complex<float> > : default_packet_traits
30 typedef Packet2cf type;
31 typedef Packet2cf half;
54 template<>
struct unpacket_traits<Packet2cf> {
55 typedef std::complex<float> type;
56 typedef Packet2cf half;
57 typedef Packet4f as_real;
62 masked_load_available=
false,
63 masked_store_available=
false 67 template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_add_ps(a.v,b.v)); }
68 template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_sub_ps(a.v,b.v)); }
70 template<> EIGEN_STRONG_INLINE Packet2cf pnegate(
const Packet2cf& a)
72 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000));
73 return Packet2cf(_mm_xor_ps(a.v,mask));
75 template<> EIGEN_STRONG_INLINE Packet2cf pconj(
const Packet2cf& a)
77 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
78 return Packet2cf(_mm_xor_ps(a.v,mask));
81 template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
83 #ifdef EIGEN_VECTORIZE_SSE3 84 return Packet2cf(_mm_addsub_ps(_mm_mul_ps(_mm_moveldup_ps(a.v), b.v),
85 _mm_mul_ps(_mm_movehdup_ps(a.v),
86 vec4f_swizzle1(b.v, 1, 0, 3, 2))));
91 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x00000000,0x80000000,0x00000000));
92 return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),
93 _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
94 vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask)));
98 template<> EIGEN_STRONG_INLINE Packet2cf ptrue <Packet2cf>(
const Packet2cf& a) {
return Packet2cf(ptrue(Packet4f(a.v))); }
99 template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_and_ps(a.v,b.v)); }
100 template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_or_ps(a.v,b.v)); }
101 template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_xor_ps(a.v,b.v)); }
102 template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_andnot_ps(b.v,a.v)); }
104 template<> EIGEN_STRONG_INLINE Packet2cf pload <Packet2cf>(
const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD
return Packet2cf(pload<Packet4f>(&numext::real_ref(*from))); }
105 template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(
const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD
return Packet2cf(ploadu<Packet4f>(&numext::real_ref(*from))); }
107 template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(
const std::complex<float>& from)
110 #ifdef EIGEN_VECTORIZE_SSE3 111 res.v = _mm_castpd_ps(_mm_loaddup_pd(reinterpret_cast<double const*>(&from)));
113 res.v = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<double const*>(&from)));
114 res.v = _mm_movelh_ps(res.v, res.v);
119 template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(
const std::complex<float>* from) {
return pset1<Packet2cf>(*from); }
121 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&numext::real_ref(*to), Packet4f(from.v)); }
122 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), Packet4f(from.v)); }
125 template<> EIGEN_DEVICE_FUNC
inline Packet2cf pgather<std::complex<float>, Packet2cf>(
const std::complex<float>* from,
Index stride)
127 return Packet2cf(_mm_set_ps(std::imag(from[1*stride]), std::real(from[1*stride]),
128 std::imag(from[0*stride]), std::real(from[0*stride])));
131 template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
const Packet2cf& from,
Index stride)
133 to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 0)),
134 _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 1)));
135 to[stride*1] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 2)),
136 _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 3)));
139 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) { _mm_prefetch((SsePrefetchPtrType)(addr), _MM_HINT_T0); }
141 template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(
const Packet2cf& a)
143 #if EIGEN_GNUC_AT_MOST(4,3) 146 EIGEN_ALIGN16 std::complex<float> res[2];
147 _mm_store_ps((
float*)res, a.v);
150 std::complex<float> res;
151 _mm_storel_pi((__m64*)&res, a.v);
156 template<> EIGEN_STRONG_INLINE Packet2cf preverse(
const Packet2cf& a) {
return Packet2cf(_mm_castpd_ps(preverse(Packet2d(_mm_castps_pd(a.v))))); }
158 template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(
const Packet2cf& a)
160 return pfirst(Packet2cf(_mm_add_ps(a.v, _mm_movehl_ps(a.v,a.v))));
163 template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(
const Packet2cf& a)
165 return pfirst(pmul(a, Packet2cf(_mm_movehl_ps(a.v,a.v))));
168 EIGEN_STRONG_INLINE Packet2cf pcplxflip(
const Packet2cf& x)
170 return Packet2cf(vec4f_swizzle1(x.v, 1, 0, 3, 2));
173 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
175 template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
178 Packet2cf res = pmul(a, pconj(b));
179 __m128 s = _mm_mul_ps(b.v,b.v);
180 return Packet2cf(_mm_div_ps(res.v,_mm_add_ps(s,vec4f_swizzle1(s, 1, 0, 3, 2))));
188 EIGEN_STRONG_INLINE Packet1cd() {}
189 EIGEN_STRONG_INLINE
explicit Packet1cd(
const __m128d& a) : v(a) {}
195 #ifndef EIGEN_VECTORIZE_AVX 196 template<>
struct packet_traits<
std::complex<double> > : default_packet_traits
198 typedef Packet1cd type;
199 typedef Packet1cd half;
221 template<>
struct unpacket_traits<Packet1cd> {
222 typedef std::complex<double> type;
223 typedef Packet1cd half;
224 typedef Packet2d as_real;
229 masked_load_available=
false,
230 masked_store_available=
false 234 template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(_mm_add_pd(a.v,b.v)); }
235 template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(_mm_sub_pd(a.v,b.v)); }
236 template<> EIGEN_STRONG_INLINE Packet1cd pnegate(
const Packet1cd& a) {
return Packet1cd(pnegate(Packet2d(a.v))); }
237 template<> EIGEN_STRONG_INLINE Packet1cd pconj(
const Packet1cd& a)
239 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
240 return Packet1cd(_mm_xor_pd(a.v,mask));
243 template<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
245 #ifdef EIGEN_VECTORIZE_SSE3 246 return Packet1cd(_mm_addsub_pd(_mm_mul_pd(_mm_movedup_pd(a.v), b.v),
247 _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
248 vec2d_swizzle1(b.v, 1, 0))));
250 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0));
251 return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),
252 _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
253 vec2d_swizzle1(b.v, 1, 0)), mask)));
257 template<> EIGEN_STRONG_INLINE Packet1cd ptrue <Packet1cd>(
const Packet1cd& a) {
return Packet1cd(ptrue(Packet2d(a.v))); }
258 template<> EIGEN_STRONG_INLINE Packet1cd pand <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(_mm_and_pd(a.v,b.v)); }
259 template<> EIGEN_STRONG_INLINE Packet1cd por <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(_mm_or_pd(a.v,b.v)); }
260 template<> EIGEN_STRONG_INLINE Packet1cd pxor <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(_mm_xor_pd(a.v,b.v)); }
261 template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(_mm_andnot_pd(b.v,a.v)); }
264 template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(
const std::complex<double>* from)
265 { EIGEN_DEBUG_ALIGNED_LOAD
return Packet1cd(pload<Packet2d>((
const double*)from)); }
266 template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(
const std::complex<double>* from)
267 { EIGEN_DEBUG_UNALIGNED_LOAD
return Packet1cd(ploadu<Packet2d>((
const double*)from)); }
268 template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(
const std::complex<double>& from)
269 {
return ploadu<Packet1cd>(&from); }
271 template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(
const std::complex<double>* from) {
return pset1<Packet1cd>(*from); }
274 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((
double*)to, Packet2d(from.v)); }
275 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((
double*)to, Packet2d(from.v)); }
277 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { _mm_prefetch((SsePrefetchPtrType)(addr), _MM_HINT_T0); }
279 template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(
const Packet1cd& a)
281 EIGEN_ALIGN16
double res[2];
282 _mm_store_pd(res, a.v);
283 return std::complex<double>(res[0],res[1]);
286 template<> EIGEN_STRONG_INLINE Packet1cd preverse(
const Packet1cd& a) {
return a; }
288 template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(
const Packet1cd& a)
293 template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(
const Packet1cd& a)
298 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
300 template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
303 Packet1cd res = pmul(a,pconj(b));
304 __m128d s = _mm_mul_pd(b.v,b.v);
305 return Packet1cd(_mm_div_pd(res.v, _mm_add_pd(s,_mm_shuffle_pd(s, s, 0x1))));
308 EIGEN_STRONG_INLINE Packet1cd pcplxflip(
const Packet1cd& x)
310 return Packet1cd(preverse(Packet2d(x.v)));
313 EIGEN_DEVICE_FUNC
inline void 314 ptranspose(PacketBlock<Packet2cf,2>& kernel) {
315 __m128d w1 = _mm_castps_pd(kernel.packet[0].v);
316 __m128d w2 = _mm_castps_pd(kernel.packet[1].v);
318 __m128 tmp = _mm_castpd_ps(_mm_unpackhi_pd(w1, w2));
319 kernel.packet[0].v = _mm_castpd_ps(_mm_unpacklo_pd(w1, w2));
320 kernel.packet[1].v = tmp;
323 template<> EIGEN_STRONG_INLINE Packet2cf pcmp_eq(
const Packet2cf& a,
const Packet2cf& b)
325 __m128 eq = _mm_cmpeq_ps(a.v, b.v);
326 return Packet2cf(pand<Packet4f>(eq, vec4f_swizzle1(eq, 1, 0, 3, 2)));
329 template<> EIGEN_STRONG_INLINE Packet1cd pcmp_eq(
const Packet1cd& a,
const Packet1cd& b)
331 __m128d eq = _mm_cmpeq_pd(a.v, b.v);
332 return Packet1cd(pand<Packet2d>(eq, vec2d_swizzle1(eq, 1, 0)));
335 template<> EIGEN_STRONG_INLINE Packet2cf pblend(
const Selector<2>& ifPacket,
const Packet2cf& thenPacket,
const Packet2cf& elsePacket) {
336 __m128d result = pblend<Packet2d>(ifPacket, _mm_castps_pd(thenPacket.v), _mm_castps_pd(elsePacket.v));
337 return Packet2cf(_mm_castpd_ps(result));
340 template<> EIGEN_STRONG_INLINE Packet1cd psqrt<Packet1cd>(
const Packet1cd& a) {
341 return psqrt_complex<Packet1cd>(a);
344 template<> EIGEN_STRONG_INLINE Packet2cf psqrt<Packet2cf>(
const Packet2cf& a) {
345 return psqrt_complex<Packet2cf>(a);
351 #endif // EIGEN_COMPLEX_SSE_H Definition: Constants.h:235
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Definition: BFloat16.h:88
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50