11#ifndef EIGEN_COMPLEX32_ALTIVEC_H
12#define EIGEN_COMPLEX32_ALTIVEC_H
18inline Packet4ui p4ui_CONJ_XOR() {
19 return vec_mergeh((Packet4ui)p4i_ZERO, (Packet4ui)p4f_MZERO);
22#if defined(_BIG_ENDIAN)
23static Packet2ul p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2d_MZERO, (Packet4ui) p2l_ZERO, 8);
24static Packet2ul p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO, (Packet4ui) p2d_MZERO, 8);
26static Packet2ul p2ul_CONJ_XOR1 = (Packet2ul) vec_sld((Packet4ui) p2l_ZERO, (Packet4ui) p2d_MZERO, 8);
27static Packet2ul p2ul_CONJ_XOR2 = (Packet2ul) vec_sld((Packet4ui) p2d_MZERO, (Packet4ui) p2l_ZERO, 8);
34 EIGEN_STRONG_INLINE
explicit Packet2cf() {}
35 EIGEN_STRONG_INLINE
explicit Packet2cf(
const Packet4f& a) : v(a) {}
37 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
42 v1 = vec_perm(a.v, a.v, p16uc_PSET32_WODD);
44 v2 = vec_perm(a.v, a.v, p16uc_PSET32_WEVEN);
46 v1 = vec_madd(v1, b.v, p4f_ZERO);
48 v2 = vec_madd(v2, b.v, p4f_ZERO);
49 v2 =
reinterpret_cast<Packet4f
>(pxor(v2,
reinterpret_cast<Packet4f
>(p4ui_CONJ_XOR())));
51 v2 = vec_perm(v2, v2, p16uc_COMPLEX32_REV);
53 return Packet2cf(padd<Packet4f>(v1, v2));
56 EIGEN_STRONG_INLINE Packet2cf& operator*=(
const Packet2cf& b) {
57 v = pmul(Packet2cf(*
this), b).v;
60 EIGEN_STRONG_INLINE Packet2cf operator*(
const Packet2cf& b)
const {
61 return Packet2cf(*
this) *= b;
64 EIGEN_STRONG_INLINE Packet2cf& operator+=(
const Packet2cf& b) {
68 EIGEN_STRONG_INLINE Packet2cf operator+(
const Packet2cf& b)
const {
69 return Packet2cf(*
this) += b;
71 EIGEN_STRONG_INLINE Packet2cf& operator-=(
const Packet2cf& b) {
75 EIGEN_STRONG_INLINE Packet2cf operator-(
const Packet2cf& b)
const {
76 return Packet2cf(*
this) -= b;
78 EIGEN_STRONG_INLINE Packet2cf operator-(
void)
const {
85template<>
struct packet_traits<std::complex<float> > : default_packet_traits
87 typedef Packet2cf type;
88 typedef Packet2cf half;
111template<>
struct unpacket_traits<Packet2cf> {
typedef std::complex<float> type;
enum {size=2, alignment=
Aligned16};
typedef Packet2cf half; };
113template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(
const std::complex<float>& from)
116 if((std::ptrdiff_t(&from) % 16) == 0)
117 res.v = pload<Packet4f>((
const float *)&from);
119 res.v = ploadu<Packet4f>((
const float *)&from);
120 res.v = vec_perm(res.v, res.v, p16uc_PSET64_HI);
124template<> EIGEN_STRONG_INLINE Packet2cf pload<Packet2cf>(
const std::complex<float>* from) {
return Packet2cf(pload<Packet4f>((
const float *) from)); }
125template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(
const std::complex<float>* from) {
return Packet2cf(ploadu<Packet4f>((
const float*) from)); }
126template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(
const std::complex<float>* from) {
return pset1<Packet2cf>(*from); }
128template<> EIGEN_STRONG_INLINE
void pstore <std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstore((
float*)to, from.v); }
129template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstoreu((
float*)to, from.v); }
131template<> EIGEN_DEVICE_FUNC
inline Packet2cf pgather<std::complex<float>, Packet2cf>(
const std::complex<float>* from,
Index stride)
133 EIGEN_ALIGN16 std::complex<float> af[2];
134 af[0] = from[0*stride];
135 af[1] = from[1*stride];
136 return pload<Packet2cf>(af);
138template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
const Packet2cf& from,
Index stride)
140 EIGEN_ALIGN16 std::complex<float> af[2];
141 pstore<std::complex<float> >((std::complex<float> *) af, from);
142 to[0*stride] = af[0];
143 to[1*stride] = af[1];
146template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v + b.v); }
147template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v - b.v); }
148template<> EIGEN_STRONG_INLINE Packet2cf pnegate(
const Packet2cf& a) {
return Packet2cf(pnegate(a.v)); }
149template<> EIGEN_STRONG_INLINE Packet2cf pconj(
const Packet2cf& a) {
return Packet2cf(pxor<Packet4f>(a.v,
reinterpret_cast<Packet4f
>(p4ui_CONJ_XOR()))); }
151template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pand<Packet4f>(a.v, b.v)); }
152template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(por<Packet4f>(a.v, b.v)); }
153template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pxor<Packet4f>(a.v, b.v)); }
154template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pandnot<Packet4f>(a.v, b.v)); }
156template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) { EIGEN_PPC_PREFETCH(addr); }
158template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(
const Packet2cf& a)
160 EIGEN_ALIGN16 std::complex<float> res[2];
161 pstore((
float *)&res, a.v);
166template<> EIGEN_STRONG_INLINE Packet2cf preverse(
const Packet2cf& a)
169 rev_a = vec_perm(a.v, a.v, p16uc_COMPLEX32_REV2);
170 return Packet2cf(rev_a);
173template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(
const Packet2cf& a)
176 b = vec_sld(a.v, a.v, 8);
177 b = padd<Packet4f>(a.v, b);
178 return pfirst<Packet2cf>(Packet2cf(b));
181template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(
const Packet2cf* vecs)
185 b1 = vec_sld(vecs[0].v, vecs[1].v, 8);
186 b2 = vec_sld(vecs[1].v, vecs[0].v, 8);
188 b1 = vec_sld(vecs[1].v, vecs[0].v, 8);
189 b2 = vec_sld(vecs[0].v, vecs[1].v, 8);
191 b2 = vec_sld(b2, b2, 8);
192 b2 = padd<Packet4f>(b1, b2);
194 return Packet2cf(b2);
197template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(
const Packet2cf& a)
201 b = vec_sld(a.v, a.v, 8);
202 prod = pmul<Packet2cf>(a, Packet2cf(b));
204 return pfirst<Packet2cf>(prod);
208struct palign_impl<Offset,Packet2cf>
210 static EIGEN_STRONG_INLINE
void run(Packet2cf& first,
const Packet2cf& second)
215 first.v = vec_sld(first.v, second.v, 8);
217 first.v = vec_sld(second.v, first.v, 8);
223template<>
struct conj_helper<Packet2cf, Packet2cf, false,true>
225 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const
226 {
return padd(pmul(x,y),c); }
228 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const
230 return internal::pmul(a, pconj(b));
234template<>
struct conj_helper<Packet2cf, Packet2cf, true,false>
236 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const
237 {
return padd(pmul(x,y),c); }
239 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const
241 return internal::pmul(pconj(a), b);
245template<>
struct conj_helper<Packet2cf, Packet2cf, true,true>
247 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const
248 {
return padd(pmul(x,y),c); }
250 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const
252 return pconj(internal::pmul(a, b));
256EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
258template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
261 Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a, b);
262 Packet4f s = pmul<Packet4f>(b.v, b.v);
263 return Packet2cf(pdiv(res.v, padd<Packet4f>(s, vec_perm(s, s, p16uc_COMPLEX32_REV))));
266template<> EIGEN_STRONG_INLINE Packet2cf pcplxflip<Packet2cf>(
const Packet2cf& x)
268 return Packet2cf(vec_perm(x.v, x.v, p16uc_COMPLEX32_REV));
271EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet2cf,2>& kernel)
273 Packet4f tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
274 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
275 kernel.packet[0].v = tmp;
279template<> EIGEN_STRONG_INLINE Packet2cf pblend(
const Selector<2>& ifPacket,
const Packet2cf& thenPacket,
const Packet2cf& elsePacket) {
281 result.v =
reinterpret_cast<Packet4f
>(pblend<Packet2d>(ifPacket,
reinterpret_cast<Packet2d
>(thenPacket.v),
reinterpret_cast<Packet2d
>(elsePacket.v)));
290 EIGEN_STRONG_INLINE Packet1cd() {}
291 EIGEN_STRONG_INLINE
explicit Packet1cd(
const Packet2d& a) : v(a) {}
293 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
295 Packet2d a_re, a_im, v1, v2;
298 a_re = vec_perm(a.v, a.v, p16uc_PSET64_HI);
300 a_im = vec_perm(a.v, a.v, p16uc_PSET64_LO);
302 v1 = vec_madd(a_re, b.v, p2d_ZERO);
304 v2 = vec_madd(a_im, b.v, p2d_ZERO);
305 v2 =
reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4ui
>(v2),
reinterpret_cast<Packet4ui
>(v2), 8));
306 v2 = pxor(v2,
reinterpret_cast<Packet2d
>(p2ul_CONJ_XOR1));
308 return Packet1cd(padd<Packet2d>(v1, v2));
311 EIGEN_STRONG_INLINE Packet1cd& operator*=(
const Packet1cd& b) {
312 v = pmul(Packet1cd(*
this), b).v;
315 EIGEN_STRONG_INLINE Packet1cd
operator*(
const Packet1cd& b)
const {
316 return Packet1cd(*
this) *= b;
319 EIGEN_STRONG_INLINE Packet1cd& operator+=(
const Packet1cd& b) {
323 EIGEN_STRONG_INLINE Packet1cd operator+(
const Packet1cd& b)
const {
324 return Packet1cd(*
this) += b;
326 EIGEN_STRONG_INLINE Packet1cd& operator-=(
const Packet1cd& b) {
330 EIGEN_STRONG_INLINE Packet1cd operator-(
const Packet1cd& b)
const {
331 return Packet1cd(*
this) -= b;
333 EIGEN_STRONG_INLINE Packet1cd operator-(
void)
const {
334 return Packet1cd(-v);
340template<>
struct packet_traits<std::complex<double> > : default_packet_traits
342 typedef Packet1cd type;
343 typedef Packet1cd half;
363template<>
struct unpacket_traits<Packet1cd> {
typedef std::complex<double> type;
enum {size=1, alignment=
Aligned16};
typedef Packet1cd half; };
365template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(pload<Packet2d>((
const double*)from)); }
366template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(ploadu<Packet2d>((
const double*)from)); }
367template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstore((
double*)to, from.v); }
368template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstoreu((
double*)to, from.v); }
370template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(
const std::complex<double>& from)
371{
return ploadu<Packet1cd>(&from); }
373template<> EIGEN_DEVICE_FUNC
inline Packet1cd pgather<std::complex<double>, Packet1cd>(
const std::complex<double>* from,
Index)
375 return pload<Packet1cd>(from);
377template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to,
const Packet1cd& from,
Index)
379 pstore<std::complex<double> >(to, from);
382template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v + b.v); }
383template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v - b.v); }
384template<> EIGEN_STRONG_INLINE Packet1cd pnegate(
const Packet1cd& a) {
return Packet1cd(pnegate(Packet2d(a.v))); }
385template<> EIGEN_STRONG_INLINE Packet1cd pconj(
const Packet1cd& a) {
return Packet1cd(pxor(a.v,
reinterpret_cast<Packet2d
>(p2ul_CONJ_XOR2))); }
387template<> EIGEN_STRONG_INLINE Packet1cd pand <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pand(a.v,b.v)); }
388template<> EIGEN_STRONG_INLINE Packet1cd por <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(por(a.v,b.v)); }
389template<> EIGEN_STRONG_INLINE Packet1cd pxor <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pxor(a.v,b.v)); }
390template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pandnot(a.v, b.v)); }
392template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(
const std::complex<double>* from) {
return pset1<Packet1cd>(*from); }
394template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { EIGEN_PPC_PREFETCH(addr); }
396template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(
const Packet1cd& a)
398 EIGEN_ALIGN16 std::complex<double> res[2];
399 pstore<std::complex<double> >(res, a);
404template<> EIGEN_STRONG_INLINE Packet1cd preverse(
const Packet1cd& a) {
return a; }
406template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
407template<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(
const Packet1cd* vecs) {
return vecs[0]; }
409template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
412struct palign_impl<Offset,Packet1cd>
414 static EIGEN_STRONG_INLINE
void run(Packet1cd& ,
const Packet1cd& )
421template<>
struct conj_helper<Packet1cd, Packet1cd, false,true>
423 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const
424 {
return padd(pmul(x,y),c); }
426 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const
428 return internal::pmul(a, pconj(b));
432template<>
struct conj_helper<Packet1cd, Packet1cd, true,false>
434 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const
435 {
return padd(pmul(x,y),c); }
437 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const
439 return internal::pmul(pconj(a), b);
443template<>
struct conj_helper<Packet1cd, Packet1cd, true,true>
445 EIGEN_STRONG_INLINE Packet1cd pmadd(
const Packet1cd& x,
const Packet1cd& y,
const Packet1cd& c)
const
446 {
return padd(pmul(x,y),c); }
448 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
const
450 return pconj(internal::pmul(a, b));
454EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
456template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
459 Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);
460 Packet2d s = pmul<Packet2d>(b.v, b.v);
461 return Packet1cd(pdiv(res.v, padd<Packet2d>(s, vec_perm(s, s, p16uc_REVERSE64))));
464EIGEN_STRONG_INLINE Packet1cd pcplxflip(
const Packet1cd& x)
466 return Packet1cd(preverse(Packet2d(x.v)));
469EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet1cd,2>& kernel)
471 Packet2d tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
472 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
473 kernel.packet[0].v = tmp;
@ Aligned16
Definition Constants.h:230
Namespace containing all symbols from the Eigen library.
Definition A05_PortingFrom2To3.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:65
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition PermutationMatrix.h:515