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() {}
33 EIGEN_STRONG_INLINE
explicit Packet2cf(
const Packet4f& a) : v(a) {}
35 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
40 v1 = vec_perm(a.v, a.v, p16uc_PSET32_WODD);
42 v2 = vec_perm(a.v, a.v, p16uc_PSET32_WEVEN);
44 v1 = vec_madd(v1, b.v, p4f_ZERO);
46 v2 = vec_madd(v2, b.v, p4f_ZERO);
47 v2 =
reinterpret_cast<Packet4f
>(pxor(v2, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR)));
49 v2 = vec_perm(v2, v2, p16uc_COMPLEX32_REV);
51 return Packet2cf(padd<Packet4f>(v1, v2));
54 EIGEN_STRONG_INLINE Packet2cf& operator*=(
const Packet2cf& b) {
55 v = pmul(Packet2cf(*
this), b).v;
58 EIGEN_STRONG_INLINE Packet2cf
operator*(
const Packet2cf& b)
const {
59 return Packet2cf(*
this) *= b;
62 EIGEN_STRONG_INLINE Packet2cf& operator+=(
const Packet2cf& b) {
66 EIGEN_STRONG_INLINE Packet2cf operator+(
const Packet2cf& b)
const {
67 return Packet2cf(*
this) += b;
69 EIGEN_STRONG_INLINE Packet2cf& operator-=(
const Packet2cf& b) {
73 EIGEN_STRONG_INLINE Packet2cf operator-(
const Packet2cf& b)
const {
74 return Packet2cf(*
this) -= b;
76 EIGEN_STRONG_INLINE Packet2cf operator-(
void)
const {
83 template<>
struct packet_traits<
std::complex<float> > : default_packet_traits
85 typedef Packet2cf type;
86 typedef Packet2cf half;
87 typedef Packet4f as_real;
110 template<>
struct unpacket_traits<Packet2cf> {
typedef std::complex<float> type;
enum {size=2, alignment=
Aligned16, vectorizable=
true, masked_load_available=
false, masked_store_available=
false};
typedef Packet2cf half;
typedef Packet4f as_real; };
112 template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(
const std::complex<float>& from)
115 if((std::ptrdiff_t(&from) % 16) == 0)
116 res.v = pload<Packet4f>((
const float *)&from);
118 res.v = ploadu<Packet4f>((
const float *)&from);
119 res.v = vec_perm(res.v, res.v, p16uc_PSET64_HI);
123 template<> EIGEN_STRONG_INLINE Packet2cf pload<Packet2cf>(
const std::complex<float>* from) {
return Packet2cf(pload<Packet4f>((
const float *) from)); }
124 template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(
const std::complex<float>* from) {
return Packet2cf(ploadu<Packet4f>((
const float*) from)); }
125 template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(
const std::complex<float>* from) {
return pset1<Packet2cf>(*from); }
127 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstore((
float*)to, from.v); }
128 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { pstoreu((
float*)to, from.v); }
130 EIGEN_STRONG_INLINE Packet2cf pload2(
const std::complex<float>* from0,
const std::complex<float>* from1)
134 __asm__ (
"lxsdx %x0,%y1" :
"=wa" (res0) :
"Z" (*from0));
135 __asm__ (
"lxsdx %x0,%y1" :
"=wa" (res1) :
"Z" (*from1));
137 __asm__ (
"xxpermdi %x0, %x1, %x2, 0" :
"=wa" (res0) :
"wa" (res0),
"wa" (res1));
139 __asm__ (
"xxpermdi %x0, %x2, %x1, 0" :
"=wa" (res0) :
"wa" (res0),
"wa" (res1));
142 *
reinterpret_cast<std::complex<float> *
>(&res0) = *from0;
143 *
reinterpret_cast<std::complex<float> *
>(&res1) = *from1;
144 res0 = vec_perm(res0, res1, p16uc_TRANSPOSE64_HI);
146 return Packet2cf(res0);
149 template<> EIGEN_DEVICE_FUNC
inline Packet2cf pgather<std::complex<float>, Packet2cf>(
const std::complex<float>* from,
Index stride)
151 EIGEN_ALIGN16 std::complex<float> af[2];
152 af[0] = from[0*stride];
153 af[1] = from[1*stride];
154 return pload<Packet2cf>(af);
156 template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
const Packet2cf& from,
Index stride)
158 EIGEN_ALIGN16 std::complex<float> af[2];
159 pstore<std::complex<float> >((std::complex<float> *) af, from);
160 to[0*stride] = af[0];
161 to[1*stride] = af[1];
164 template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v + b.v); }
165 template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(a.v - b.v); }
166 template<> EIGEN_STRONG_INLINE Packet2cf pnegate(
const Packet2cf& a) {
return Packet2cf(pnegate(a.v)); }
167 template<> EIGEN_STRONG_INLINE Packet2cf pconj(
const Packet2cf& a) {
return Packet2cf(pxor<Packet4f>(a.v, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR))); }
169 template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pand<Packet4f>(a.v, b.v)); }
170 template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(por<Packet4f>(a.v, b.v)); }
171 template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pxor<Packet4f>(a.v, b.v)); }
172 template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(pandnot<Packet4f>(a.v, b.v)); }
174 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) { EIGEN_PPC_PREFETCH(addr); }
176 template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(
const Packet2cf& a)
178 EIGEN_ALIGN16 std::complex<float> res[2];
179 pstore((
float *)&res, a.v);
184 template<> EIGEN_STRONG_INLINE Packet2cf preverse(
const Packet2cf& a)
187 rev_a = vec_perm(a.v, a.v, p16uc_COMPLEX32_REV2);
188 return Packet2cf(rev_a);
191 template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(
const Packet2cf& a)
194 b = vec_sld(a.v, a.v, 8);
195 b = padd<Packet4f>(a.v, b);
196 return pfirst<Packet2cf>(Packet2cf(b));
199 template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(
const Packet2cf& a)
203 b = vec_sld(a.v, a.v, 8);
204 prod = pmul<Packet2cf>(a, Packet2cf(b));
206 return pfirst<Packet2cf>(prod);
209 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
211 template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
214 Packet2cf res = pmul(a, pconj(b));
215 Packet4f s = pmul<Packet4f>(b.v, b.v);
216 return Packet2cf(pdiv(res.v, padd<Packet4f>(s, vec_perm(s, s, p16uc_COMPLEX32_REV))));
219 template<> EIGEN_STRONG_INLINE Packet2cf pcplxflip<Packet2cf>(
const Packet2cf& x)
221 return Packet2cf(vec_perm(x.v, x.v, p16uc_COMPLEX32_REV));
224 EIGEN_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;
231 template<> 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)));
237 template<> 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)));
244 template<> EIGEN_STRONG_INLINE Packet2cf psqrt<Packet2cf>(
const Packet2cf& a)
246 return psqrt_complex<Packet2cf>(a);
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);
303 template<>
struct packet_traits<
std::complex<double> > : default_packet_traits
305 typedef Packet1cd type;
306 typedef Packet1cd half;
307 typedef Packet2d as_real;
327 template<>
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; };
329 template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(pload<Packet2d>((
const double*)from)); }
330 template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(
const std::complex<double>* from) {
return Packet1cd(ploadu<Packet2d>((
const double*)from)); }
331 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstore((
double*)to, from.v); }
332 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { pstoreu((
double*)to, from.v); }
334 template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(
const std::complex<double>& from)
335 {
return ploadu<Packet1cd>(&from); }
337 template<> EIGEN_DEVICE_FUNC
inline Packet1cd pgather<std::complex<double>, Packet1cd>(
const std::complex<double>* from,
Index)
339 return pload<Packet1cd>(from);
341 template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to,
const Packet1cd& from,
Index)
343 pstore<std::complex<double> >(to, from);
346 template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v + b.v); }
347 template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(a.v - b.v); }
348 template<> EIGEN_STRONG_INLINE Packet1cd pnegate(
const Packet1cd& a) {
return Packet1cd(pnegate(Packet2d(a.v))); }
349 template<> EIGEN_STRONG_INLINE Packet1cd pconj(
const Packet1cd& a) {
return Packet1cd(pxor(a.v, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR2))); }
351 template<> EIGEN_STRONG_INLINE Packet1cd pand <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pand(a.v,b.v)); }
352 template<> EIGEN_STRONG_INLINE Packet1cd por <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(por(a.v,b.v)); }
353 template<> EIGEN_STRONG_INLINE Packet1cd pxor <Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pxor(a.v,b.v)); }
354 template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b) {
return Packet1cd(pandnot(a.v, b.v)); }
356 template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(
const std::complex<double>* from) {
return pset1<Packet1cd>(*from); }
358 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { EIGEN_PPC_PREFETCH(addr); }
360 template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(
const Packet1cd& a)
362 EIGEN_ALIGN16 std::complex<double> res[2];
363 pstore<std::complex<double> >(res, a);
368 template<> EIGEN_STRONG_INLINE Packet1cd preverse(
const Packet1cd& a) {
return a; }
370 template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
372 template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(
const Packet1cd& a) {
return pfirst(a); }
374 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
376 template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(
const Packet1cd& a,
const Packet1cd& b)
379 Packet1cd res = pmul(a,pconj(b));
380 Packet2d s = pmul<Packet2d>(b.v, b.v);
381 return Packet1cd(pdiv(res.v, padd<Packet2d>(s, vec_perm(s, s, p16uc_REVERSE64))));
384 EIGEN_STRONG_INLINE Packet1cd pcplxflip(
const Packet1cd& x)
386 return Packet1cd(preverse(Packet2d(x.v)));
389 EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet1cd,2>& kernel)
391 Packet2d tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
392 kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
393 kernel.packet[0].v = tmp;
396 template<> EIGEN_STRONG_INLINE Packet1cd pcmp_eq(
const Packet1cd& a,
const Packet1cd& b) {
399 Packet2d eq =
reinterpret_cast<Packet2d
>(vec_cmpeq(a.v,b.v));
402 Packet2d eq_swapped =
reinterpret_cast<Packet2d
>(vec_sld(reinterpret_cast<Packet4ui>(eq), reinterpret_cast<Packet4ui>(eq), 8));
404 return Packet1cd(vec_and(eq, eq_swapped));
407 template<> EIGEN_STRONG_INLINE Packet1cd psqrt<Packet1cd>(
const Packet1cd& a)
409 return psqrt_complex<Packet1cd>(a);
417 #endif // EIGEN_COMPLEX32_ALTIVEC_H Definition: Constants.h:235
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Definition: BFloat16.h:88
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:515
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50