11 #ifndef EIGEN_COMPLEX32_ALTIVEC_H
12 #define EIGEN_COMPLEX32_ALTIVEC_H
14 #include "../../InternalHeaderCheck.h"
21 #ifdef EIGEN_VECTORIZE_VSX
22 #if defined(_BIG_ENDIAN)
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)
46 v1 = vec_madd(
v1,
b.v, p4f_ZERO);
48 v2 = vec_madd(
v2,
b.v, p4f_ZERO);
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 {
85 template<>
struct packet_traits<
std::complex<float> > : default_packet_traits
87 typedef Packet2cf type;
88 typedef Packet2cf half;
105 #ifdef EIGEN_VECTORIZE_VSX
112 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; };
117 #ifdef EIGEN_VECTORIZE_VSX
122 __asm__ (
"lxvdsx %x0,%y1" :
"=wa" (
res.v) :
"Z" (from));
124 if((std::ptrdiff_t(&from) % 16) == 0)
145 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) {
pstore((
float*)to, from.v); }
146 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) {
pstoreu((
float*)to, from.v); }
150 EIGEN_STRONG_INLINE Packet2cf
pload2(
const std::complex<float>& from0,
const std::complex<float>& from1)
153 #ifdef EIGEN_VECTORIZE_VSX
155 __asm__ (
"lxsdx %x0,%y1" :
"=wa" (res0) :
"Z" (from0));
156 __asm__ (
"lxsdx %x0,%y1" :
"=wa" (res1) :
"Z" (from1));
158 __asm__ (
"xxpermdi %x0, %x1, %x2, 0" :
"=wa" (res0) :
"wa" (res0),
"wa" (res1));
160 __asm__ (
"xxpermdi %x0, %x2, %x1, 0" :
"=wa" (res0) :
"wa" (res0),
"wa" (res1));
163 *
reinterpret_cast<std::complex<float> *
>(&res0) = from0;
164 *
reinterpret_cast<std::complex<float> *
>(&res1) = from1;
167 return Packet2cf(res0);
173 res.v = pload_ignore<Packet4f>(
reinterpret_cast<const float*
>(from));
182 af[
i] = from[
i*stride];
184 return pload_ignore<Packet>(af);
188 return pgather_complex_size2<std::complex<float>, Packet2cf>(from, stride);
192 return pgather_complex_size2<std::complex<float>, Packet2cf>(from, stride,
n);
198 pstore<Scalar>((Scalar *) af, from);
200 to[
i*stride] = af[
i];
205 pscatter_complex_size2<std::complex<float>, Packet2cf>(to, from, stride);
209 pscatter_complex_size2<std::complex<float>, Packet2cf>(to, from, stride,
n);
212 template<> EIGEN_STRONG_INLINE Packet2cf
padd<Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(
a.v +
b.v); }
213 template<> EIGEN_STRONG_INLINE Packet2cf
psub<Packet2cf>(
const Packet2cf&
a,
const Packet2cf&
b) {
return Packet2cf(
a.v -
b.v); }
214 template<> EIGEN_STRONG_INLINE Packet2cf
pnegate(
const Packet2cf&
a) {
return Packet2cf(
pnegate(
a.v)); }
222 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) {
EIGEN_PPC_PREFETCH(addr); }
224 template<> EIGEN_STRONG_INLINE std::complex<float>
pfirst<Packet2cf>(
const Packet2cf&
a)
232 template<> EIGEN_STRONG_INLINE Packet2cf
preverse(
const Packet2cf&
a)
235 rev_a = vec_sld(
a.v,
a.v, 8);
236 return Packet2cf(rev_a);
239 template<> EIGEN_STRONG_INLINE std::complex<float>
predux<Packet2cf>(
const Packet2cf&
a)
242 b = vec_sld(
a.v,
a.v, 8);
251 b = vec_sld(
a.v,
a.v, 8);
259 template<> EIGEN_STRONG_INLINE Packet2cf
pdiv<Packet2cf>(const Packet2cf&
a, const Packet2cf&
b)
269 EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet2cf,2>& kernel)
271 #ifdef EIGEN_VECTORIZE_VSX
273 kernel.packet[1].v =
reinterpret_cast<Packet4f>(vec_mergel(
reinterpret_cast<Packet2d>(kernel.packet[0].v),
reinterpret_cast<Packet2d>(kernel.packet[1].v)));
278 kernel.packet[0].v = tmp;
281 template<> EIGEN_STRONG_INLINE Packet2cf
pcmp_eq(
const Packet2cf&
a,
const Packet2cf&
b) {
286 #ifdef EIGEN_VECTORIZE_VSX
287 template<> EIGEN_STRONG_INLINE Packet2cf
pblend(
const Selector<2>& ifPacket,
const Packet2cf& thenPacket,
const Packet2cf& elsePacket) {
289 result.v =
reinterpret_cast<Packet4f>(pblend<Packet2d>(ifPacket,
reinterpret_cast<Packet2d>(thenPacket.v),
reinterpret_cast<Packet2d>(elsePacket.v)));
296 return psqrt_complex<Packet2cf>(
a);
300 #ifdef EIGEN_VECTORIZE_VSX
303 EIGEN_STRONG_INLINE Packet1cd() {}
304 EIGEN_STRONG_INLINE
explicit Packet1cd(
const Packet2d&
a) :
v(
a) {}
306 EIGEN_STRONG_INLINE Packet1cd
pmul(
const Packet1cd&
a,
const Packet1cd&
b)
315 v1 = vec_madd(a_re,
b.v, p2d_ZERO);
317 v2 = vec_madd(a_im,
b.v, p2d_ZERO);
324 EIGEN_STRONG_INLINE Packet1cd&
operator*=(
const Packet1cd&
b) {
325 v =
pmul(Packet1cd(*
this),
b).v;
328 EIGEN_STRONG_INLINE Packet1cd
operator*(
const Packet1cd&
b)
const {
329 return Packet1cd(*
this) *=
b;
332 EIGEN_STRONG_INLINE Packet1cd&
operator+=(
const Packet1cd&
b) {
336 EIGEN_STRONG_INLINE Packet1cd
operator+(
const Packet1cd&
b)
const {
337 return Packet1cd(*
this) +=
b;
339 EIGEN_STRONG_INLINE Packet1cd&
operator-=(
const Packet1cd&
b) {
343 EIGEN_STRONG_INLINE Packet1cd
operator-(
const Packet1cd&
b)
const {
344 return Packet1cd(*
this) -=
b;
346 EIGEN_STRONG_INLINE Packet1cd
operator-(
void)
const {
347 return Packet1cd(-
v);
353 template<>
struct packet_traits<
std::complex<double> > : default_packet_traits
355 typedef Packet1cd type;
356 typedef Packet1cd half;
377 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; };
383 return Packet1cd(pload_partial<Packet2d>((
const double*)from,
n * 2, offset * 2));
387 return Packet1cd(ploadu_partial<Packet2d>((
const double*)from,
n * 2, offset * 2));
389 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) {
pstore((
double*)to, from.v); }
390 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) {
pstoreu((
double*)to, from.v); }
394 template<> EIGEN_STRONG_INLINE Packet1cd
pset1<Packet1cd>(
const std::complex<double>& from)
407 pstore<std::complex<double> >(to, from);
411 pstore<std::complex<double> >(to, from);
414 template<> EIGEN_STRONG_INLINE Packet1cd
padd<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(
a.v +
b.v); }
415 template<> EIGEN_STRONG_INLINE Packet1cd
psub<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(
a.v -
b.v); }
419 template<> EIGEN_STRONG_INLINE Packet1cd
pand <Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(
pand(
a.v,
b.v)); }
420 template<> EIGEN_STRONG_INLINE Packet1cd
por <Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(
por(
a.v,
b.v)); }
421 template<> EIGEN_STRONG_INLINE Packet1cd
pxor <Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b) {
return Packet1cd(
pxor(
a.v,
b.v)); }
426 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) {
EIGEN_PPC_PREFETCH(addr); }
428 template<> EIGEN_STRONG_INLINE std::complex<double>
pfirst<Packet1cd>(
const Packet1cd&
a)
431 pstore<std::complex<double> >(
res,
a);
436 template<> EIGEN_STRONG_INLINE Packet1cd
preverse(
const Packet1cd&
a) {
return a; }
444 template<> EIGEN_STRONG_INLINE Packet1cd
pdiv<Packet1cd>(
const Packet1cd&
a,
const Packet1cd&
b)
449 EIGEN_STRONG_INLINE Packet1cd
pcplxflip(
const Packet1cd&
x)
454 EIGEN_STRONG_INLINE
void ptranspose(PacketBlock<Packet1cd,2>& kernel)
456 Packet2d tmp = vec_mergeh(kernel.packet[0].v, kernel.packet[1].v);
457 kernel.packet[1].v = vec_mergel(kernel.packet[0].v, kernel.packet[1].v);
458 kernel.packet[0].v = tmp;
461 template<> EIGEN_STRONG_INLINE Packet1cd
pcmp_eq(
const Packet1cd&
a,
const Packet1cd&
b) {
469 return Packet1cd(vec_and(eq, eq_swapped));
474 return psqrt_complex<Packet1cd>(
a);
#define EIGEN_PPC_PREFETCH(ADDR)
Array< int, Dynamic, 1 > v
#define EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(PACKET_CPLX, PACKET_REAL)
#define EIGEN_ALWAYS_INLINE
#define eigen_internal_assert(x)
#define EIGEN_DEVICE_FUNC
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Map< RowVectorXf > v2(M2.data(), M2.size())
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
bfloat16 & operator*=(bfloat16 &a, const bfloat16 &b)
bfloat16 & operator+=(bfloat16 &a, const bfloat16 &b)
bfloat16 & operator-=(bfloat16 &a, const bfloat16 &b)
EIGEN_ALWAYS_INLINE Packet4f pload_partial< Packet4f >(const float *from, const Index n, const Index offset)
Packet padd(const Packet &a, const Packet &b)
static Packet2ul p2ul_CONJ_XOR2
Packet1cd pxor< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf pandnot< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
void pstore(Scalar *to, const Packet &from)
std::complex< float > predux< Packet2cf >(const Packet2cf &a)
Packet1cd pload< Packet1cd >(const std::complex< double > *from)
Packet2cf padd< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet2cf ploaddup< Packet2cf >(const std::complex< float > *from)
std::complex< float > pfirst< Packet2cf >(const Packet2cf &a)
Packet2cf pset1< Packet2cf >(const std::complex< float > &from)
Packet4f pxor< Packet4f >(const Packet4f &a, const Packet4f &b)
Packet1cd pdiv< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet1cd pandnot< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf ploadu< Packet2cf >(const std::complex< float > *from)
Packet4f por< Packet4f >(const Packet4f &a, const Packet4f &b)
static Packet16uc p16uc_TRANSPOSE64_LO
Packet4f pandnot< Packet4f >(const Packet4f &a, const Packet4f &b)
Packet8h pandnot(const Packet8h &a, const Packet8h &b)
Packet1cd padd< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
void pstore_partial(Scalar *to, const Packet &from, const Index n, const Index offset=0)
Packet2cf pnegate(const Packet2cf &a)
Packet1cd ploadu< Packet1cd >(const std::complex< double > *from)
Packet4f pand< Packet4f >(const Packet4f &a, const Packet4f &b)
Packet2cf por< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet1cd pcplxflip(const Packet1cd &x)
static Packet16uc p16uc_PSET32_WEVEN
std::complex< double > pfirst< Packet1cd >(const Packet1cd &a)
EIGEN_ALWAYS_INLINE void pscatter_complex_size2(Scalar *to, const Packet &from, Index stride, const Index n=2)
void pstoreu(Scalar *to, const Packet &from)
Packet2cf pcmp_eq(const Packet2cf &a, const Packet2cf &b)
bfloat16 pfirst(const Packet8bf &a)
void pstoreu_partial(Scalar *to, const Packet &from, const Index n, const Index offset=0)
Packet2cf pmul< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
__vector unsigned int Packet4ui
Packet pmul(const Packet &a, const Packet &b)
void ptranspose(PacketBlock< Packet2cf, 2 > &kernel)
static Packet4ui p4ui_CONJ_XOR
EIGEN_ALWAYS_INLINE Packet2cf pload_partial< Packet2cf >(const std::complex< float > *from, const Index n, const Index offset)
static Packet2ul p2ul_CONJ_XOR1
EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pdiv_complex(const Packet &x, const Packet &y)
Packet2cf pcplxflip< Packet2cf >(const Packet2cf &x)
Packet1cd pand< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf pxor< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet4f padd< Packet4f >(const Packet4f &a, const Packet4f &b)
Packet4f ploadu< Packet4f >(const float *from)
std::complex< double > predux_mul< Packet1cd >(const Packet1cd &a)
Packet2d padd< Packet2d >(const Packet2d &a, const Packet2d &b)
Packet psub(const Packet &a, const Packet &b)
static Packet4f p4f_MZERO
std::complex< double > predux< Packet1cd >(const Packet1cd &a)
Packet1cd por< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet8h pand(const Packet8h &a, const Packet8h &b)
Packet2d ploadu< Packet2d >(const double *from)
EIGEN_ALWAYS_INLINE Packet pgather_complex_size2(const Scalar *from, Index stride, const Index n=2)
Packet2cf pload< Packet2cf >(const std::complex< float > *from)
Packet2cf pload2(const std::complex< float > &from0, const std::complex< float > &from1)
static Packet16uc p16uc_PSET64_HI
Packet2cf pand< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet8h pxor(const Packet8h &a, const Packet8h &b)
Packet1cd ploaddup< Packet1cd >(const std::complex< double > *from)
Packet1cd psqrt< Packet1cd >(const Packet1cd &a)
Packet pdiv(const Packet &a, const Packet &b)
Packet4i pblend(const Selector< 4 > &ifPacket, const Packet4i &thenPacket, const Packet4i &elsePacket)
Packet1cd pset1< Packet1cd >(const std::complex< double > &from)
Packet2cf pconj(const Packet2cf &a)
EIGEN_ALWAYS_INLINE Packet2cf pload_ignore< Packet2cf >(const std::complex< float > *from)
EIGEN_ALWAYS_INLINE Packet4f ploadu_partial< Packet4f >(const float *from, const Index n, const Index offset)
Packet2d pload< Packet2d >(const double *from)
static Packet16uc p16uc_PSET32_WODD
Packet2cf preverse(const Packet2cf &a)
static Packet16uc p16uc_PSET64_LO
Packet4f pload< Packet4f >(const float *from)
static Packet16uc p16uc_COMPLEX32_REV
Packet8h por(const Packet8h &a, const Packet8h &b)
EIGEN_ALWAYS_INLINE Packet2cf ploadu_partial< Packet2cf >(const std::complex< float > *from, const Index n, const Index offset)
Packet2cf psub< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Packet1cd psub< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Packet2cf psqrt< Packet2cf >(const Packet2cf &a)
std::complex< float > predux_mul< Packet2cf >(const Packet2cf &a)
static Packet16uc p16uc_TRANSPOSE64_HI
const CwiseBinaryOp< internal::scalar_difference_op< typename DenseDerived::Scalar, typename SparseDerived::Scalar >, const DenseDerived, const SparseDerived > operator-(const MatrixBase< DenseDerived > &a, const SparseMatrixBase< SparseDerived > &b)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
const CwiseBinaryOp< internal::scalar_sum_op< typename DenseDerived::Scalar, typename SparseDerived::Scalar >, const DenseDerived, const SparseDerived > operator+(const MatrixBase< DenseDerived > &a, const SparseMatrixBase< SparseDerived > &b)