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);
21#ifdef EIGEN_VECTORIZE_VSX
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() {}
78 EIGEN_STRONG_INLINE
Packet2cf operator-(
void)
const {
106#ifdef EIGEN_VECTORIZE_VSX
118 if((std::ptrdiff_t(&from) % 16) == 0)
122 res.v =
vec_perm(res.v, res.v, p16uc_PSET64_HI);
127template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(
const std::complex<float>* from) {
return Packet2cf(ploadu<Packet4f>((
const float*) from)); }
128template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(
const std::complex<float>* from) {
return pset1<Packet2cf>(*from); }
130template<> EIGEN_STRONG_INLINE
void pstore <std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstore((
float*)to, from.v); }
131template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstoreu((
float*)to, from.v); }
133EIGEN_STRONG_INLINE Packet2cf pload2(
const std::complex<float>& from0,
const std::complex<float>& from1)
136#ifdef EIGEN_VECTORIZE_VSX
137 __asm__ (
"lxsdx %x0,%y1" :
"=wa" (res0) :
"Z" (from0));
138 __asm__ (
"lxsdx %x0,%y1" :
"=wa" (res1) :
"Z" (from1));
140 __asm__ (
"xxpermdi %x0, %x1, %x2, 0" :
"=wa" (res0) :
"wa" (res0),
"wa" (res1));
142 __asm__ (
"xxpermdi %x0, %x2, %x1, 0" :
"=wa" (res0) :
"wa" (res0),
"wa" (res1));
145 *
reinterpret_cast<std::complex<float> *
>(&res0) = from0;
146 *
reinterpret_cast<std::complex<float> *
>(&res1) = from1;
147 res0 = vec_perm(res0, res1, p16uc_TRANSPOSE64_HI);
149 return Packet2cf(res0);
152template<> EIGEN_DEVICE_FUNC
inline Packet2cf pgather<std::complex<float>, Packet2cf>(
const std::complex<float>* from,
Index stride)
154 EIGEN_ALIGN16 std::complex<float> af[2];
155 af[0] = from[0*stride];
156 af[1] = from[1*stride];
157 return pload<Packet2cf>(af);
159template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
const Packet2cf& from,
Index stride)
161 EIGEN_ALIGN16 std::complex<float> af[2];
162 pstore<std::complex<float> >((std::complex<float> *) af, from);
163 to[0*stride] = af[0];
164 to[1*stride] = af[1];
167template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v + b.v); }
168template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v - b.v); }
169template<> EIGEN_STRONG_INLINE Packet2cf pnegate(
const Packet2cf& a) {
return Packet2cf(pnegate(a.v)); }
170template<> EIGEN_STRONG_INLINE Packet2cf pconj(
const Packet2cf& a) {
return Packet2cf(pxor<Packet4f>(a.v,
reinterpret_cast<Packet4f
>(p4ui_CONJ_XOR()))); }
172template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pand<Packet4f>(a.v, b.v)); }
173template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(por<Packet4f>(a.v, b.v)); }
174template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pxor<Packet4f>(a.v, b.v)); }
175template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pandnot<Packet4f>(a.v, b.v)); }
177template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) { EIGEN_PPC_PREFETCH(addr); }
179template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(
const Packet2cf& a)
181 EIGEN_ALIGN16 std::complex<float> res[2];
182 pstore((
float *)&res, a.v);
187template<> EIGEN_STRONG_INLINE Packet2cf preverse(
const Packet2cf& a)
190 rev_a = vec_perm(a.v, a.v, p16uc_COMPLEX32_REV2);
191 return Packet2cf(rev_a);
194template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(
const Packet2cf& a)
197 b = vec_sld(a.v, a.v, 8);
198 b = padd<Packet4f>(a.v, b);
199 return pfirst<Packet2cf>(Packet2cf(b));
202template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(
const Packet2cf& a)
206 b = vec_sld(a.v, a.v, 8);
207 prod = pmul<Packet2cf>(a, Packet2cf(b));
209 return pfirst<Packet2cf>(prod);
212EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
214template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
216 return pdiv_complex(a, b);
219template<> EIGEN_STRONG_INLINE Packet2cf pcplxflip<Packet2cf>(
const Packet2cf& x)
221 return Packet2cf(vec_perm(x.v, x.v, p16uc_COMPLEX32_REV));
224EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet2cf,2>& kernel)
226 Packet4f tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
227 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
228 kernel.packet[0].v = tmp;
231template<> EIGEN_STRONG_INLINE Packet2cf pcmp_eq(
const Packet2cf& a,
const Packet2cf& b) {
232 Packet4f eq =
reinterpret_cast<Packet4f
>(vec_cmpeq(a.v,b.v));
233 return Packet2cf(vec_and(eq, vec_perm(eq, eq, p16uc_COMPLEX32_REV)));
236#ifdef EIGEN_VECTORIZE_VSX
237template<> EIGEN_STRONG_INLINE Packet2cf pblend(
const Selector<2>& ifPacket,
const Packet2cf& thenPacket,
const Packet2cf& elsePacket) {
239 result.v =
reinterpret_cast<Packet4f
>(pblend<Packet2d>(ifPacket,
reinterpret_cast<Packet2d
>(thenPacket.v),
reinterpret_cast<Packet2d
>(elsePacket.v)));
243template<> EIGEN_STRONG_INLINE Packet2cf psqrt<Packet2cf>(
const Packet2cf& a)
245 return psqrt_complex<Packet2cf>(a);
250#ifdef EIGEN_VECTORIZE_VSX
253 EIGEN_STRONG_INLINE Packet1cd() {}
254 EIGEN_STRONG_INLINE
explicit Packet1cd(
const Packet2d& a) : v(a) {}
256 EIGEN_STRONG_INLINE Packet1cd pmul(
const Packet1cd& a,
const Packet1cd& b)
258 Packet2d a_re, a_im, v1, v2;
261 a_re = vec_perm(a.v, a.v, p16uc_PSET64_HI);
263 a_im = vec_perm(a.v, a.v, p16uc_PSET64_LO);
265 v1 = vec_madd(a_re, b.v, p2d_ZERO);
267 v2 = vec_madd(a_im, b.v, p2d_ZERO);
268 v2 =
reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4ui
>(v2),
reinterpret_cast<Packet4ui
>(v2), 8));
269 v2 = pxor(v2,
reinterpret_cast<Packet2d
>(p2ul_CONJ_XOR1));
271 return Packet1cd(padd<Packet2d>(v1, v2));
274 EIGEN_STRONG_INLINE Packet1cd& operator*=(
const Packet1cd& b) {
275 v = pmul(Packet1cd(*
this), b).v;
278 EIGEN_STRONG_INLINE Packet1cd operator*(
const Packet1cd& b)
const {
279 return Packet1cd(*
this) *= b;
282 EIGEN_STRONG_INLINE Packet1cd& operator+=(
const Packet1cd& b) {
286 EIGEN_STRONG_INLINE Packet1cd operator+(
const Packet1cd& b)
const {
287 return Packet1cd(*
this) += b;
289 EIGEN_STRONG_INLINE Packet1cd& operator-=(
const Packet1cd& b) {
293 EIGEN_STRONG_INLINE Packet1cd operator-(
const Packet1cd& b)
const {
294 return Packet1cd(*
this) -= b;
296 EIGEN_STRONG_INLINE Packet1cd operator-(
void)
const {
297 return Packet1cd(-v);
303template<>
struct packet_traits<
std::complex<double> > : default_packet_traits
305 typedef Packet1cd type;
306 typedef Packet1cd half;
307 typedef Packet2d as_real;
328template<>
struct unpacket_traits<Packet1cd> {
typedef std::complex<double> type;
enum {size=1, alignment=
Aligned16, vectorizable=
true, masked_load_available=
false, masked_store_available=
false};
typedef Packet1cd half;
typedef Packet2d as_real; };
330template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(pload<Packet2d>((
const double*)from)); }
331template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(ploadu<Packet2d>((
const double*)from)); }
332template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstore((
double*)to, from.v); }
333template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstoreu((
double*)to, from.v); }
335template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(
const std::complex<double>& from)
336{
return ploadu<Packet1cd>(&from); }
338template<> EIGEN_DEVICE_FUNC
inline Packet1cd pgather<std::complex<double>, Packet1cd>(
const std::complex<double>* from,
Index)
340 return pload<Packet1cd>(from);
342template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to,
const Packet1cd& from,
Index)
344 pstore<std::complex<double> >(to, from);
347template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v + b.v); }
348template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v - b.v); }
349template<> EIGEN_STRONG_INLINE Packet1cd pnegate(
const Packet1cd& a) {
return Packet1cd(pnegate(Packet2d(a.v))); }
350template<> EIGEN_STRONG_INLINE Packet1cd pconj(
const Packet1cd& a) {
return Packet1cd(pxor(a.v,
reinterpret_cast<Packet2d
>(p2ul_CONJ_XOR2))); }
352template<> EIGEN_STRONG_INLINE Packet1cd pand <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pand(a.v,b.v)); }
353template<> EIGEN_STRONG_INLINE Packet1cd por <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(por(a.v,b.v)); }
354template<> EIGEN_STRONG_INLINE Packet1cd pxor <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pxor(a.v,b.v)); }
355template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pandnot(a.v, b.v)); }
357template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(
const std::complex<double>* from) {
return pset1<Packet1cd>(*from); }
359template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { EIGEN_PPC_PREFETCH(addr); }
361template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(
const Packet1cd& a)
363 EIGEN_ALIGN16 std::complex<double> res[2];
364 pstore<std::complex<double> >(res, a);
369template<> EIGEN_STRONG_INLINE Packet1cd preverse(
const Packet1cd& a) {
return a; }
371template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
373template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
375EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
377template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
379 return pdiv_complex(a, b);
382EIGEN_STRONG_INLINE Packet1cd pcplxflip(
const Packet1cd& x)
384 return Packet1cd(preverse(Packet2d(x.v)));
387EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet1cd,2>& kernel)
389 Packet2d tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
390 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
391 kernel.packet[0].v = tmp;
394template<> EIGEN_STRONG_INLINE Packet1cd pcmp_eq(
const Packet1cd& a,
const Packet1cd& b) {
397 Packet2d eq =
reinterpret_cast<Packet2d
>(vec_cmpeq(a.v,b.v));
400 Packet2d eq_swapped =
reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4ui
>(eq),
reinterpret_cast<Packet4ui
>(eq), 8));
402 return Packet1cd(vec_and(eq, eq_swapped));
405template<> EIGEN_STRONG_INLINE Packet1cd psqrt<Packet1cd>(
const Packet1cd& a)
407 return psqrt_complex<Packet1cd>(a);
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
@ Aligned16
Data pointer is aligned on a 16 bytes boundary.
Definition Constants.h:235
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Definition GenericPacketMath.h:43
Definition GenericPacketMath.h:107
Definition GenericPacketMath.h:133