10 #ifndef EIGEN_COMPLEX_SSE_H
11 #define EIGEN_COMPLEX_SSE_H
13 #include "../../InternalHeaderCheck.h"
22 EIGEN_STRONG_INLINE Packet2cf() {}
23 EIGEN_STRONG_INLINE
explicit Packet2cf(
const __m128&
a) :
v(
a) {}
29 #ifndef EIGEN_VECTORIZE_AVX
30 template<>
struct packet_traits<
std::complex<float> > : default_packet_traits
32 typedef Packet2cf type;
33 typedef Packet2cf half;
55 template<>
struct unpacket_traits<Packet2cf> {
56 typedef std::complex<float> type;
57 typedef Packet2cf half;
63 masked_load_available=
false,
64 masked_store_available=
false
68 template<> EIGEN_STRONG_INLINE Packet2cf
padd<Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(_mm_add_ps(
a.v,
b.v)); }
69 template<> EIGEN_STRONG_INLINE Packet2cf
psub<Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(_mm_sub_ps(
a.v,
b.v)); }
71 template<> EIGEN_STRONG_INLINE Packet2cf
pnegate(
const Packet2cf&
a)
73 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000));
74 return Packet2cf(_mm_xor_ps(
a.v,mask));
76 template<> EIGEN_STRONG_INLINE Packet2cf
pconj(
const Packet2cf&
a)
78 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
79 return Packet2cf(_mm_xor_ps(
a.v,mask));
82 template<> EIGEN_STRONG_INLINE Packet2cf
pmul<Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b)
84 #ifdef EIGEN_VECTORIZE_SSE3
85 return Packet2cf(_mm_addsub_ps(_mm_mul_ps(_mm_moveldup_ps(
a.v),
b.v),
86 _mm_mul_ps(_mm_movehdup_ps(
a.v),
92 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x00000000,0x80000000,0x00000000));
93 return Packet2cf(_mm_add_ps(_mm_mul_ps(
vec4f_swizzle1(
a.v, 0, 0, 2, 2),
b.v),
100 template<> EIGEN_STRONG_INLINE Packet2cf
pand <Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(_mm_and_ps(
a.v,
b.v)); }
101 template<> EIGEN_STRONG_INLINE Packet2cf
por <Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(_mm_or_ps(
a.v,
b.v)); }
102 template<> EIGEN_STRONG_INLINE Packet2cf
pxor <Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(_mm_xor_ps(
a.v,
b.v)); }
103 template<> EIGEN_STRONG_INLINE Packet2cf
pandnot<Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(_mm_andnot_ps(
b.v,
a.v)); }
108 template<> EIGEN_STRONG_INLINE Packet2cf
pset1<Packet2cf>(
const std::complex<float>& from)
112 return Packet2cf(_mm_set_ps(im, re, im, re));
121 template<>
EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(
const std::complex<float>* from,
Index stride)
127 template<>
EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
const Packet2cf& from,
Index stride)
129 to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 0)),
130 _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 1)));
131 to[stride*1] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 2)),
132 _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 3)));
135 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) { _mm_prefetch((
SsePrefetchPtrType)(addr), _MM_HINT_T0); }
137 template<> EIGEN_STRONG_INLINE std::complex<float>
pfirst<Packet2cf>(
const Packet2cf&
a)
139 alignas(
alignof(__m64)) std::complex<float>
res;
140 _mm_storel_pi((__m64*)&
res,
a.v);
144 template<> EIGEN_STRONG_INLINE Packet2cf
preverse(
const Packet2cf&
a) {
return Packet2cf(_mm_castpd_ps(
preverse(
Packet2d(_mm_castps_pd(
a.v))))); }
146 template<> EIGEN_STRONG_INLINE std::complex<float>
predux<Packet2cf>(
const Packet2cf&
a)
148 return pfirst(Packet2cf(_mm_add_ps(
a.v, _mm_movehl_ps(
a.v,
a.v))));
163 template<> EIGEN_STRONG_INLINE Packet2cf
pdiv<Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b)
171 EIGEN_STRONG_INLINE Packet1cd() {}
172 EIGEN_STRONG_INLINE
explicit Packet1cd(
const __m128d&
a) :
v(
a) {}
178 #ifndef EIGEN_VECTORIZE_AVX
179 template<>
struct packet_traits<
std::complex<double> > : default_packet_traits
181 typedef Packet1cd type;
182 typedef Packet1cd half;
203 template<>
struct unpacket_traits<Packet1cd> {
204 typedef std::complex<double> type;
205 typedef Packet1cd half;
211 masked_load_available=
false,
212 masked_store_available=
false
216 template<> EIGEN_STRONG_INLINE Packet1cd
padd<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(_mm_add_pd(
a.v,
b.v)); }
217 template<> EIGEN_STRONG_INLINE Packet1cd
psub<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(_mm_sub_pd(
a.v,
b.v)); }
219 template<> EIGEN_STRONG_INLINE Packet1cd
pconj(
const Packet1cd&
a)
221 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
222 return Packet1cd(_mm_xor_pd(
a.v,mask));
225 template<> EIGEN_STRONG_INLINE Packet1cd
pmul<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b)
227 #ifdef EIGEN_VECTORIZE_SSE3
228 return Packet1cd(_mm_addsub_pd(_mm_mul_pd(_mm_movedup_pd(
a.v),
b.v),
232 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0));
240 template<> EIGEN_STRONG_INLINE Packet1cd
pand <Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(_mm_and_pd(
a.v,
b.v)); }
241 template<> EIGEN_STRONG_INLINE Packet1cd
por <Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(_mm_or_pd(
a.v,
b.v)); }
242 template<> EIGEN_STRONG_INLINE Packet1cd
pxor <Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(_mm_xor_pd(
a.v,
b.v)); }
243 template<> EIGEN_STRONG_INLINE Packet1cd
pandnot<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(_mm_andnot_pd(
b.v,
a.v)); }
246 template<> EIGEN_STRONG_INLINE Packet1cd
pload <Packet1cd>(
const std::complex<double>* from)
248 template<> EIGEN_STRONG_INLINE Packet1cd
ploadu<Packet1cd>(
const std::complex<double>* from)
250 template<> EIGEN_STRONG_INLINE Packet1cd
pset1<Packet1cd>(
const std::complex<double>& from)
259 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { _mm_prefetch((
SsePrefetchPtrType)(addr), _MM_HINT_T0); }
261 template<> EIGEN_STRONG_INLINE std::complex<double>
pfirst<Packet1cd>(
const Packet1cd&
a)
264 _mm_store_pd(
res,
a.v);
265 return std::complex<double>(
res[0],
res[1]);
268 template<> EIGEN_STRONG_INLINE Packet1cd
preverse(
const Packet1cd&
a) {
return a; }
270 template<> EIGEN_STRONG_INLINE std::complex<double>
predux<Packet1cd>(
const Packet1cd&
a)
282 template<> EIGEN_STRONG_INLINE Packet1cd
pdiv<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b)
287 EIGEN_STRONG_INLINE Packet1cd
pcplxflip(
const Packet1cd&
x)
293 ptranspose(PacketBlock<Packet2cf,2>& kernel) {
294 __m128d w1 = _mm_castps_pd(kernel.packet[0].v);
295 __m128d w2 = _mm_castps_pd(kernel.packet[1].v);
297 __m128 tmp = _mm_castpd_ps(_mm_unpackhi_pd(w1, w2));
298 kernel.packet[0].v = _mm_castpd_ps(_mm_unpacklo_pd(w1, w2));
299 kernel.packet[1].v = tmp;
302 template<> EIGEN_STRONG_INLINE Packet2cf
pcmp_eq(
const Packet2cf&
a,
const Packet2cf&
b)
304 __m128 eq = _mm_cmpeq_ps(
a.v,
b.v);
308 template<> EIGEN_STRONG_INLINE Packet1cd
pcmp_eq(
const Packet1cd&
a,
const Packet1cd&
b)
310 __m128d eq = _mm_cmpeq_pd(
a.v,
b.v);
314 template<> EIGEN_STRONG_INLINE Packet2cf
pblend(
const Selector<2>& ifPacket,
const Packet2cf& thenPacket,
const Packet2cf& elsePacket) {
315 __m128d result = pblend<Packet2d>(ifPacket, _mm_castps_pd(thenPacket.v), _mm_castps_pd(elsePacket.v));
316 return Packet2cf(_mm_castpd_ps(result));
320 return psqrt_complex<Packet1cd>(
a);
324 return psqrt_complex<Packet2cf>(
a);
Array< int, Dynamic, 1 > v
const ImagReturnType imag() const
RealReturnType real() const
#define EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(PACKET_CPLX, PACKET_REAL)
#define EIGEN_DEBUG_ALIGNED_STORE
#define EIGEN_DEBUG_ALIGNED_LOAD
#define EIGEN_DEBUG_UNALIGNED_STORE
#define EIGEN_DEBUG_UNALIGNED_LOAD
#define EIGEN_DEVICE_FUNC
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define vec2d_swizzle1(v, p, q)
Packet1cd pxor< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf pandnot< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
void pstore(Scalar *to, const Packet &from)
std::complex< float > predux< Packet2cf >(const Packet2cf &a)
Packet1cd pload< Packet1cd >(const std::complex< double > *from)
Packet2cf padd< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet8h ptrue(const Packet8h &a)
Packet2cf ploaddup< Packet2cf >(const std::complex< float > *from)
std::complex< float > pfirst< Packet2cf >(const Packet2cf &a)
Packet2cf pset1< Packet2cf >(const std::complex< float > &from)
Packet1cd pmul< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet1cd pdiv< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet1cd pandnot< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf ploadu< Packet2cf >(const std::complex< float > *from)
Packet1cd padd< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf pnegate(const Packet2cf &a)
Packet1cd ploadu< Packet1cd >(const std::complex< double > *from)
Packet4f pand< Packet4f >(const Packet4f &a, const Packet4f &b)
Packet2cf por< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet1cd pcplxflip(const Packet1cd &x)
Packet2d pand< Packet2d >(const Packet2d &a, const Packet2d &b)
std::complex< double > pfirst< Packet1cd >(const Packet1cd &a)
Packet2cf ptrue< Packet2cf >(const Packet2cf &a)
void pstoreu(Scalar *to, const Packet &from)
Packet2cf pcmp_eq(const Packet2cf &a, const Packet2cf &b)
bfloat16 pfirst(const Packet8bf &a)
Packet2cf pmul< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet pmul(const Packet &a, const Packet &b)
void ptranspose(PacketBlock< Packet2cf, 2 > &kernel)
Packet1cd ptrue< Packet1cd >(const Packet1cd &a)
EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pdiv_complex(const Packet &x, const Packet &y)
Packet1cd pand< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf pxor< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet4f ploadu< Packet4f >(const float *from)
std::complex< double > predux_mul< Packet1cd >(const Packet1cd &a)
std::complex< double > predux< Packet1cd >(const Packet1cd &a)
Packet1cd por< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2d ploadu< Packet2d >(const double *from)
const char * SsePrefetchPtrType
Packet2cf pload< Packet2cf >(const std::complex< float > *from)
Packet2cf pand< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet1cd ploaddup< Packet1cd >(const std::complex< double > *from)
Packet1cd psqrt< Packet1cd >(const Packet1cd &a)
Packet4i pblend(const Selector< 4 > &ifPacket, const Packet4i &thenPacket, const Packet4i &elsePacket)
Packet1cd pset1< Packet1cd >(const std::complex< double > &from)
Packet2cf pconj(const Packet2cf &a)
Packet2cf pdiv< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet2d pload< Packet2d >(const double *from)
Packet2cf preverse(const Packet2cf &a)
Packet4f pload< Packet4f >(const float *from)
Packet2cf psub< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet1cd psub< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet4f vec4f_swizzle1(const Packet4f &a, int p, int q, int r, int s)
Packet2cf psqrt< Packet2cf >(const Packet2cf &a)
std::complex< float > predux_mul< Packet2cf >(const Packet2cf &a)
internal::add_const_on_value_type_t< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) > real_ref(const Scalar &x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.