11 #ifndef EIGEN_COMPLEX32_ALTIVEC_H 12 #define EIGEN_COMPLEX32_ALTIVEC_H 18 static Packet4ui p4ui_CONJ_XOR = vec_mergeh((Packet4ui)p4i_ZERO, (Packet4ui)p4f_MZERO);
20 #if defined(_BIG_ENDIAN) 21 static Packet2ul p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2d_MZERO, (Packet4ui) p2l_ZERO, 8);
22 static Packet2ul p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO, (Packet4ui) p2d_MZERO, 8);
24 static Packet2ul p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO, (Packet4ui) p2d_MZERO, 8);
25 static Packet2ul p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2d_MZERO, (Packet4ui) p2l_ZERO, 8);
32 EIGEN_STRONG_INLINE
explicit Packet2cf() : v(p4f_ZERO) {}
33 EIGEN_STRONG_INLINE
explicit Packet2cf(
const Packet4f& a) : v(a) {}
37 template<>
struct packet_traits<
std::complex<float> > : default_packet_traits
39 typedef Packet2cf type;
40 typedef Packet2cf half;
63 template<>
struct unpacket_traits<Packet2cf> {
typedef std::complex<float> type;
enum {size=2, alignment=
Aligned16};
typedef Packet2cf half; };
65 template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(
const std::complex<float>& from)
68 if((std::ptrdiff_t(&from) % 16) == 0)
69 res.v = pload<Packet4f>((
const float *)&from);
71 res.v = ploadu<Packet4f>((
const float *)&from);
72 res.v = vec_perm(res.v, res.v, p16uc_PSET64_HI);
76 template<> EIGEN_STRONG_INLINE Packet2cf pload<Packet2cf>(
const std::complex<float>* from) {
return Packet2cf(pload<Packet4f>((
const float *) from)); }
77 template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(
const std::complex<float>* from) {
return Packet2cf(ploadu<Packet4f>((
const float*) from)); }
78 template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(
const std::complex<float>* from) {
return pset1<Packet2cf>(*from); }
80 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstore((
float*)to, from.v); }
81 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstoreu((
float*)to, from.v); }
83 template<> EIGEN_DEVICE_FUNC
inline Packet2cf pgather<std::complex<float>, Packet2cf>(
const std::complex<float>* from,
Index stride)
85 std::complex<float> EIGEN_ALIGN16 af[2];
86 af[0] = from[0*stride];
87 af[1] = from[1*stride];
88 return pload<Packet2cf>(af);
90 template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
const Packet2cf& from,
Index stride)
92 std::complex<float> EIGEN_ALIGN16 af[2];
93 pstore<std::complex<float> >((std::complex<float> *) af, from);
98 template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v + b.v); }
99 template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v - b.v); }
100 template<> EIGEN_STRONG_INLINE Packet2cf pnegate(
const Packet2cf& a) {
return Packet2cf(pnegate(a.v)); }
101 template<> EIGEN_STRONG_INLINE Packet2cf pconj(
const Packet2cf& a) {
return Packet2cf(pxor<Packet4f>(a.v, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR))); }
103 template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
108 v1 = vec_perm(a.v, a.v, p16uc_PSET32_WODD);
110 v2 = vec_perm(a.v, a.v, p16uc_PSET32_WEVEN);
112 v1 = vec_madd(v1, b.v, p4f_ZERO);
114 v2 = vec_madd(v2, b.v, p4f_ZERO);
115 v2 =
reinterpret_cast<Packet4f
>(pxor(v2, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR)));
117 v2 = vec_perm(v2, v2, p16uc_COMPLEX32_REV);
119 return Packet2cf(padd<Packet4f>(v1, v2));
122 template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pand<Packet4f>(a.v, b.v)); }
123 template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(por<Packet4f>(a.v, b.v)); }
124 template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pxor<Packet4f>(a.v, b.v)); }
125 template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pandnot<Packet4f>(a.v, b.v)); }
127 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) { EIGEN_PPC_PREFETCH(addr); }
129 template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(
const Packet2cf& a)
131 std::complex<float> EIGEN_ALIGN16 res[2];
132 pstore((
float *)&res, a.v);
137 template<> EIGEN_STRONG_INLINE Packet2cf preverse(
const Packet2cf& a)
140 rev_a = vec_perm(a.v, a.v, p16uc_COMPLEX32_REV2);
141 return Packet2cf(rev_a);
144 template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(
const Packet2cf& a)
147 b = vec_sld(a.v, a.v, 8);
148 b = padd<Packet4f>(a.v, b);
149 return pfirst<Packet2cf>(Packet2cf(b));
152 template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(
const Packet2cf* vecs)
156 b1 = vec_sld(vecs[0].v, vecs[1].v, 8);
157 b2 = vec_sld(vecs[1].v, vecs[0].v, 8);
159 b1 = vec_sld(vecs[1].v, vecs[0].v, 8);
160 b2 = vec_sld(vecs[0].v, vecs[1].v, 8);
162 b2 = vec_sld(b2, b2, 8);
163 b2 = padd<Packet4f>(b1, b2);
165 return Packet2cf(b2);
168 template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(
const Packet2cf& a)
172 b = vec_sld(a.v, a.v, 8);
173 prod = pmul<Packet2cf>(a, Packet2cf(b));
175 return pfirst<Packet2cf>(prod);
179 struct palign_impl<Offset,Packet2cf>
181 static EIGEN_STRONG_INLINE
void run(Packet2cf& first,
const Packet2cf& second)
186 first.v = vec_sld(first.v, second.v, 8);
188 first.v = vec_sld(second.v, first.v, 8);
194 template<>
struct conj_helper<Packet2cf, Packet2cf, false,true>
196 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const 197 {
return padd(pmul(x,y),c); }
199 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const 201 return internal::pmul(a, pconj(b));
205 template<>
struct conj_helper<Packet2cf, Packet2cf, true,false>
207 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const 208 {
return padd(pmul(x,y),c); }
210 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const 212 return internal::pmul(pconj(a), b);
216 template<>
struct conj_helper<Packet2cf, Packet2cf, true,true>
218 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const 219 {
return padd(pmul(x,y),c); }
221 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const 223 return pconj(internal::pmul(a, b));
227 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
229 template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
232 Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a, b);
233 Packet4f s = pmul<Packet4f>(b.v, b.v);
234 return Packet2cf(pdiv(res.v, padd<Packet4f>(s, vec_perm(s, s, p16uc_COMPLEX32_REV))));
237 template<> EIGEN_STRONG_INLINE Packet2cf pcplxflip<Packet2cf>(
const Packet2cf& x)
239 return Packet2cf(vec_perm(x.v, x.v, p16uc_COMPLEX32_REV));
242 EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet2cf,2>& kernel)
244 Packet4f tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
245 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
246 kernel.packet[0].v = tmp;
250 template<> EIGEN_STRONG_INLINE Packet2cf pblend(
const Selector<2>& ifPacket,
const Packet2cf& thenPacket,
const Packet2cf& elsePacket) {
252 result.v =
reinterpret_cast<Packet4f
>(pblend<Packet2d>(ifPacket,
reinterpret_cast<Packet2d
>(thenPacket.v), reinterpret_cast<Packet2d>(elsePacket.v)));
261 EIGEN_STRONG_INLINE Packet1cd() {}
262 EIGEN_STRONG_INLINE
explicit Packet1cd(
const Packet2d& a) : v(a) {}
266 template<>
struct packet_traits<
std::complex<double> > : default_packet_traits
268 typedef Packet1cd type;
269 typedef Packet1cd half;
289 template<>
struct unpacket_traits<Packet1cd> {
typedef std::complex<double> type;
enum {size=1, alignment=
Aligned16};
typedef Packet1cd half; };
291 template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(pload<Packet2d>((
const double*)from)); }
292 template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(ploadu<Packet2d>((
const double*)from)); }
293 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstore((
double*)to, from.v); }
294 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstoreu((
double*)to, from.v); }
296 template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(
const std::complex<double>& from)
297 {
return ploadu<Packet1cd>(&from); }
299 template<> EIGEN_DEVICE_FUNC
inline Packet1cd pgather<std::complex<double>, Packet1cd>(
const std::complex<double>* from,
Index stride)
301 std::complex<double> EIGEN_ALIGN16 af[2];
302 af[0] = from[0*stride];
303 af[1] = from[1*stride];
304 return pload<Packet1cd>(af);
306 template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to,
const Packet1cd& from,
Index stride)
308 std::complex<double> EIGEN_ALIGN16 af[2];
309 pstore<std::complex<double> >(af, from);
310 to[0*stride] = af[0];
311 to[1*stride] = af[1];
314 template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v + b.v); }
315 template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v - b.v); }
316 template<> EIGEN_STRONG_INLINE Packet1cd pnegate(
const Packet1cd& a) {
return Packet1cd(pnegate(Packet2d(a.v))); }
317 template<> EIGEN_STRONG_INLINE Packet1cd pconj(
const Packet1cd& a) {
return Packet1cd(pxor(a.v, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR2))); }
319 template<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
321 Packet2d a_re, a_im, v1, v2;
324 a_re = vec_perm(a.v, a.v, p16uc_PSET64_HI);
326 a_im = vec_perm(a.v, a.v, p16uc_PSET64_LO);
328 v1 = vec_madd(a_re, b.v, p2d_ZERO);
330 v2 = vec_madd(a_im, b.v, p2d_ZERO);
331 v2 =
reinterpret_cast<Packet2d
>(vec_sld(reinterpret_cast<Packet4ui>(v2), reinterpret_cast<Packet4ui>(v2), 8));
332 v2 = pxor(v2, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR1));
334 return Packet1cd(padd<Packet2d>(v1, v2));
337 template<> EIGEN_STRONG_INLINE Packet1cd pand <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pand(a.v,b.v)); }
338 template<> EIGEN_STRONG_INLINE Packet1cd por <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(por(a.v,b.v)); }
339 template<> EIGEN_STRONG_INLINE Packet1cd pxor <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pxor(a.v,b.v)); }
340 template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pandnot(a.v, b.v)); }
342 template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(
const std::complex<double>* from) {
return pset1<Packet1cd>(*from); }
344 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { EIGEN_PPC_PREFETCH(addr); }
346 template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(
const Packet1cd& a)
348 std::complex<double> EIGEN_ALIGN16 res[2];
349 pstore<std::complex<double> >(res, a);
354 template<> EIGEN_STRONG_INLINE Packet1cd preverse(
const Packet1cd& a) {
return a; }
356 template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
357 template<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(
const Packet1cd* vecs) {
return vecs[0]; }
359 template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
362 struct palign_impl<Offset,Packet1cd>
364 static EIGEN_STRONG_INLINE
void run(Packet1cd& ,
const Packet1cd& )
371 template<>
struct conj_helper<Packet1cd, Packet1cd, false,true>
373 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const 374 {
return padd(pmul(x,y),c); }
376 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const 378 return internal::pmul(a, pconj(b));
382 template<>
struct conj_helper<Packet1cd, Packet1cd, true,false>
384 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const 385 {
return padd(pmul(x,y),c); }
387 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const 389 return internal::pmul(pconj(a), b);
393 template<>
struct conj_helper<Packet1cd, Packet1cd, true,true>
395 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const 396 {
return padd(pmul(x,y),c); }
398 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const 400 return pconj(internal::pmul(a, b));
404 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
406 template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
409 Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);
410 Packet2d s = pmul<Packet2d>(b.v, b.v);
411 return Packet1cd(pdiv(res.v, padd<Packet2d>(s, vec_perm(s, s, p16uc_REVERSE64))));
414 EIGEN_STRONG_INLINE Packet1cd pcplxflip(
const Packet1cd& x)
416 return Packet1cd(preverse(Packet2d(x.v)));
419 EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet1cd,2>& kernel)
421 Packet2d tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
422 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
423 kernel.packet[0].v = tmp;
430 #endif // EIGEN_COMPLEX32_ALTIVEC_H Definition: Constants.h:230
Namespace containing all symbols from the Eigen library.
Definition: Core:287
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: Eigen_Colamd.h:50