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_ZERO_);
20 #if defined(_BIG_ENDIAN) 21 static Packet2ul p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2d_ZERO_, (Packet4ui) p2l_ZERO, 8);
22 static Packet2ul p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO, (Packet4ui) p2d_ZERO_, 8);
24 static Packet2ul p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO, (Packet4ui) p2d_ZERO_, 8);
25 static Packet2ul p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2d_ZERO_, (Packet4ui) p2l_ZERO, 8);
32 EIGEN_STRONG_INLINE
explicit Packet2cf() : v(p4f_ZERO) {}
33 EIGEN_STRONG_INLINE
explicit Packet2cf(
const Packet4f& a) : v(a) {}
65 template<> EIGEN_STRONG_INLINE
Packet2cf pset1<Packet2cf>(
const std::complex<float>& from)
68 if((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);
101 template<> EIGEN_STRONG_INLINE
Packet2cf pconj(
const Packet2cf& a) {
return Packet2cf(pxor<Packet4f>(a.v, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR))); }
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));
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);
140 rev_a = vec_perm(a.v, a.v, p16uc_COMPLEX32_REV2);
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);
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);
168 template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(
const Packet2cf& a)
172 b = vec_sld(a.v, a.v, 8);
175 return pfirst<Packet2cf>(prod);
186 first.v = vec_sld(first.v, second.v, 8);
188 first.v = vec_sld(second.v, first.v, 8);
197 {
return padd(pmul(x,y),c); }
201 return internal::pmul(a, pconj(b));
208 {
return padd(pmul(x,y),c); }
212 return internal::pmul(pconj(a), b);
219 {
return padd(pmul(x,y),c); }
223 return pconj(internal::pmul(a, b));
230 {
return padd(c, pmul(x,y)); }
233 {
return Packet2cf(internal::pmul<Packet4f>(x, y.v)); }
239 {
return padd(c, pmul(x,y)); }
242 {
return Packet2cf(internal::pmul<Packet4f>(x.v, y)); }
249 Packet4f s = pmul<Packet4f>(b.v, b.v);
250 return Packet2cf(pdiv(res.v, padd<Packet4f>(s, vec_perm(s, s, p16uc_COMPLEX32_REV))));
255 return Packet2cf(vec_perm(x.v, x.v, p16uc_COMPLEX32_REV));
260 Packet4f tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
261 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
262 kernel.packet[0].v = tmp;
268 result.v =
reinterpret_cast<Packet4f>(pblend<Packet2d>(ifPacket,
reinterpret_cast<Packet2d
>(thenPacket.v), reinterpret_cast<Packet2d>(elsePacket.v)));
278 EIGEN_STRONG_INLINE
explicit Packet1cd(
const Packet2d& a) : v(a) {}
305 template<>
struct unpacket_traits<Packet1cd> {
typedef std::complex<double> type;
enum {size=1, alignment=
Aligned16};
typedef Packet1cd
half; };
307 template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(pload<Packet2d>((
const double*)from)); }
308 template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(ploadu<Packet2d>((
const double*)from)); }
309 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstore((
double*)to, from.v); }
310 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstoreu((
double*)to, from.v); }
312 template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(
const std::complex<double>& from)
313 {
return ploadu<Packet1cd>(&from); }
315 template<> EIGEN_DEVICE_FUNC
inline Packet1cd pgather<std::complex<double>, Packet1cd>(
const std::complex<double>* from,
Index stride)
317 std::complex<double> EIGEN_ALIGN16 af[2];
318 af[0] = from[0*stride];
319 af[1] = from[1*stride];
320 return pload<Packet1cd>(af);
322 template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to,
const Packet1cd& from,
Index stride)
324 std::complex<double> EIGEN_ALIGN16 af[2];
325 pstore<std::complex<double> >(af, from);
326 to[0*stride] = af[0];
327 to[1*stride] = af[1];
330 template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v + b.v); }
331 template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v - b.v); }
332 template<> EIGEN_STRONG_INLINE Packet1cd pnegate(
const Packet1cd& a) {
return Packet1cd(pnegate(Packet2d(a.v))); }
333 template<> EIGEN_STRONG_INLINE Packet1cd pconj(
const Packet1cd& a) {
return Packet1cd(pxor(a.v, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR2))); }
335 template<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
337 Packet2d a_re, a_im, v1, v2;
340 a_re = vec_perm(a.v, a.v, p16uc_PSET64_HI);
342 a_im = vec_perm(a.v, a.v, p16uc_PSET64_LO);
344 v1 = vec_madd(a_re, b.v, p2d_ZERO);
346 v2 = vec_madd(a_im, b.v, p2d_ZERO);
347 v2 =
reinterpret_cast<Packet2d
>(vec_sld(reinterpret_cast<Packet4ui>(v2), reinterpret_cast<Packet4ui>(v2), 8));
348 v2 = pxor(v2, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR1));
350 return Packet1cd(padd<Packet2d>(v1, v2));
353 template<> EIGEN_STRONG_INLINE Packet1cd pand <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pand(a.v,b.v)); }
354 template<> EIGEN_STRONG_INLINE Packet1cd por <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(por(a.v,b.v)); }
355 template<> EIGEN_STRONG_INLINE Packet1cd pxor <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pxor(a.v,b.v)); }
356 template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pandnot(a.v, b.v)); }
358 template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(
const std::complex<double>* from) {
return pset1<Packet1cd>(*from); }
360 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { EIGEN_PPC_PREFETCH(addr); }
362 template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(
const Packet1cd& a)
364 std::complex<double> EIGEN_ALIGN16 res[2];
365 pstore<std::complex<double> >(res, a);
370 template<> EIGEN_STRONG_INLINE Packet1cd preverse(
const Packet1cd& a) {
return a; }
372 template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
373 template<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(
const Packet1cd* vecs) {
return vecs[0]; }
375 template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
380 static EIGEN_STRONG_INLINE
void run(Packet1cd& ,
const Packet1cd& )
387 template<>
struct conj_helper<Packet1cd, Packet1cd, false,true>
389 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const 390 {
return padd(pmul(x,y),c); }
392 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const 394 return internal::pmul(a, pconj(b));
398 template<>
struct conj_helper<Packet1cd, Packet1cd, true,false>
400 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const 401 {
return padd(pmul(x,y),c); }
403 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const 405 return internal::pmul(pconj(a), b);
409 template<>
struct conj_helper<Packet1cd, Packet1cd, true,true>
411 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const 412 {
return padd(pmul(x,y),c); }
414 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const 416 return pconj(internal::pmul(a, b));
419 template<>
struct conj_helper<Packet2d, Packet1cd, false,false>
421 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet2d& x,
const Packet1cd& y,
const Packet1cd& c)
const 422 {
return padd(c, pmul(x,y)); }
424 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet2d& x,
const Packet1cd& y)
const 425 {
return Packet1cd(internal::pmul<Packet2d>(x, y.v)); }
428 template<>
struct conj_helper<Packet1cd, Packet2d, false,false>
430 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet2d& y,
const Packet1cd& c)
const 431 {
return padd(c, pmul(x,y)); }
433 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& x,
const Packet2d& y)
const 434 {
return Packet1cd(internal::pmul<Packet2d>(x.v, y)); }
437 template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
441 Packet2d s = pmul<Packet2d>(b.v, b.v);
442 return Packet1cd(pdiv(res.v, padd<Packet2d>(s, vec_perm(s, s, p16uc_REVERSE64))));
445 EIGEN_STRONG_INLINE Packet1cd pcplxflip(
const Packet1cd& x)
447 return Packet1cd(preverse(Packet2d(x.v)));
452 Packet2d tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
453 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
454 kernel.packet[0].v = tmp;
461 #endif // EIGEN_COMPLEX32_ALTIVEC_H
Data pointer is aligned on a 16 bytes boundary.
Definition: Constants.h:230
Definition: BlasUtil.h:61
Definition: XprHelper.h:158
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Definition: GenericPacketMath.h:96
Definition: Complex.h:265
Definition: GenericPacketMath.h:42
Definition: Complex.h:379
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: Complex.h:194
Definition: GenericPacketMath.h:539
Definition: BandTriangularSolver.h:13
Definition: datatypes.h:12
Definition: GenericPacketMath.h:492
Definition: PacketMath.h:44
Definition: GenericPacketMath.h:552