AltiVec/Complex.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2010-2016 Konstantinos Margaritis <markos@freevec.org>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_COMPLEX32_ALTIVEC_H
12 #define EIGEN_COMPLEX32_ALTIVEC_H
13 
14 // IWYU pragma: private
15 #include "../../InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
19 namespace internal {
20 
22  vec_mergeh((Packet4ui)p4i_ZERO, (Packet4ui)p4f_MZERO); //{ 0x00000000, 0x80000000, 0x00000000, 0x80000000 };
23 #ifdef EIGEN_VECTORIZE_VSX
24 #if defined(_BIG_ENDIAN)
26  (Packet2ul)vec_sld((Packet4ui)p2d_MZERO, (Packet4ui)p2l_ZERO, 8); //{ 0x8000000000000000, 0x0000000000000000 };
28  (Packet2ul)vec_sld((Packet4ui)p2l_ZERO, (Packet4ui)p2d_MZERO, 8); //{ 0x8000000000000000, 0x0000000000000000 };
29 #else
31  (Packet2ul)vec_sld((Packet4ui)p2l_ZERO, (Packet4ui)p2d_MZERO, 8); //{ 0x8000000000000000, 0x0000000000000000 };
33  (Packet2ul)vec_sld((Packet4ui)p2d_MZERO, (Packet4ui)p2l_ZERO, 8); //{ 0x8000000000000000, 0x0000000000000000 };
34 #endif
35 #endif
36 
37 //---------- float ----------
38 struct Packet2cf {
40  EIGEN_STRONG_INLINE explicit Packet2cf(const Packet4f& a) : v(a) {}
41 
43  Packet4f v1, v2;
44 
45  // Permute and multiply the real parts of a and b
46  v1 = vec_perm(a.v, a.v, p16uc_PSET32_WODD);
47  // Get the imaginary parts of a
48  v2 = vec_perm(a.v, a.v, p16uc_PSET32_WEVEN);
49  // multiply a_re * b
50  v1 = vec_madd(v1, b.v, p4f_ZERO);
51  // multiply a_im * b and get the conjugate result
52  v2 = vec_madd(v2, b.v, p4f_ZERO);
53  v2 = reinterpret_cast<Packet4f>(pxor(v2, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR)));
54  // permute back to a proper order
55  v2 = vec_perm(v2, v2, p16uc_COMPLEX32_REV);
56 
57  return Packet2cf(padd<Packet4f>(v1, v2));
58  }
59 
61  v = pmul(Packet2cf(*this), b).v;
62  return *this;
63  }
64  EIGEN_STRONG_INLINE Packet2cf operator*(const Packet2cf& b) const { return Packet2cf(*this) *= b; }
65 
67  v = padd(v, b.v);
68  return *this;
69  }
70  EIGEN_STRONG_INLINE Packet2cf operator+(const Packet2cf& b) const { return Packet2cf(*this) += b; }
72  v = psub(v, b.v);
73  return *this;
74  }
75  EIGEN_STRONG_INLINE Packet2cf operator-(const Packet2cf& b) const { return Packet2cf(*this) -= b; }
77 
79 };
80 
81 template <>
83  typedef Packet2cf type;
84  typedef Packet2cf half;
85  typedef Packet4f as_real;
86  enum {
89  size = 2,
90 
91  HasAdd = 1,
92  HasSub = 1,
93  HasMul = 1,
94  HasDiv = 1,
95  HasNegate = 1,
96  HasAbs = 0,
97  HasAbs2 = 0,
98  HasMin = 0,
99  HasMax = 0,
100  HasSqrt = 1,
101  HasLog = 1,
102  HasExp = 1,
103 #ifdef EIGEN_VECTORIZE_VSX
104  HasBlend = 1,
105 #endif
106  HasSetLinear = 0
107  };
108 };
109 
110 template <>
112  typedef std::complex<float> type;
113  enum {
114  size = 2,
116  vectorizable = true,
118  masked_store_available = false
119  };
120  typedef Packet2cf half;
121  typedef Packet4f as_real;
122 };
123 
124 template <>
125 EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>& from) {
126  Packet2cf res;
127 #ifdef EIGEN_VECTORIZE_VSX
128  // Load a single std::complex<float> from memory and duplicate
129  //
130  // Using pload would read past the end of the reference in this case
131  // Using vec_xl_len + vec_splat, generates poor assembly
132  __asm__("lxvdsx %x0,%y1" : "=wa"(res.v) : "Z"(from));
133 #else
134  if ((std::ptrdiff_t(&from) % 16) == 0)
135  res.v = pload<Packet4f>((const float*)&from);
136  else
137  res.v = ploadu<Packet4f>((const float*)&from);
138  res.v = vec_perm(res.v, res.v, p16uc_PSET64_HI);
139 #endif
140  return res;
141 }
142 
143 template <>
144 EIGEN_STRONG_INLINE Packet2cf pload<Packet2cf>(const std::complex<float>* from) {
145  return Packet2cf(pload<Packet4f>((const float*)from));
146 }
147 template <>
148 EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>* from) {
149  return Packet2cf(ploadu<Packet4f>((const float*)from));
150 }
151 template <>
152 EIGEN_ALWAYS_INLINE Packet2cf pload_partial<Packet2cf>(const std::complex<float>* from, const Index n,
153  const Index offset) {
154  return Packet2cf(pload_partial<Packet4f>((const float*)from, n * 2, offset * 2));
155 }
156 template <>
157 EIGEN_ALWAYS_INLINE Packet2cf ploadu_partial<Packet2cf>(const std::complex<float>* from, const Index n,
158  const Index offset) {
159  return Packet2cf(ploadu_partial<Packet4f>((const float*)from, n * 2, offset * 2));
160 }
161 template <>
162 EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>* from) {
163  return pset1<Packet2cf>(*from);
164 }
165 
166 template <>
167 EIGEN_STRONG_INLINE void pstore<std::complex<float> >(std::complex<float>* to, const Packet2cf& from) {
168  pstore((float*)to, from.v);
169 }
170 template <>
171 EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float>* to, const Packet2cf& from) {
172  pstoreu((float*)to, from.v);
173 }
174 template <>
175 EIGEN_ALWAYS_INLINE void pstore_partial<std::complex<float> >(std::complex<float>* to, const Packet2cf& from,
176  const Index n, const Index offset) {
177  pstore_partial((float*)to, from.v, n * 2, offset * 2);
178 }
179 template <>
180 EIGEN_ALWAYS_INLINE void pstoreu_partial<std::complex<float> >(std::complex<float>* to, const Packet2cf& from,
181  const Index n, const Index offset) {
182  pstoreu_partial((float*)to, from.v, n * 2, offset * 2);
183 }
184 
185 EIGEN_STRONG_INLINE Packet2cf pload2(const std::complex<float>& from0, const std::complex<float>& from1) {
186  Packet4f res0, res1;
187 #ifdef EIGEN_VECTORIZE_VSX
188  // Load two std::complex<float> from memory and combine
189  __asm__("lxsdx %x0,%y1" : "=wa"(res0) : "Z"(from0));
190  __asm__("lxsdx %x0,%y1" : "=wa"(res1) : "Z"(from1));
191 #ifdef _BIG_ENDIAN
192  __asm__("xxpermdi %x0, %x1, %x2, 0" : "=wa"(res0) : "wa"(res0), "wa"(res1));
193 #else
194  __asm__("xxpermdi %x0, %x2, %x1, 0" : "=wa"(res0) : "wa"(res0), "wa"(res1));
195 #endif
196 #else
197  *reinterpret_cast<std::complex<float>*>(&res0) = from0;
198  *reinterpret_cast<std::complex<float>*>(&res1) = from1;
199  res0 = vec_perm(res0, res1, p16uc_TRANSPOSE64_HI);
200 #endif
201  return Packet2cf(res0);
202 }
203 
204 template <>
205 EIGEN_ALWAYS_INLINE Packet2cf pload_ignore<Packet2cf>(const std::complex<float>* from) {
206  Packet2cf res;
207  res.v = pload_ignore<Packet4f>(reinterpret_cast<const float*>(from));
208  return res;
209 }
210 
211 template <typename Scalar, typename Packet>
213  const Index n = 2) {
214  eigen_internal_assert(n <= unpacket_traits<Packet>::size && "number of elements will gather past end of packet");
215  EIGEN_ALIGN16 Scalar af[2];
216  for (Index i = 0; i < n; i++) {
217  af[i] = from[i * stride];
218  }
219  return pload_ignore<Packet>(af);
220 }
221 template <>
222 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from,
223  Index stride) {
224  return pgather_complex_size2<std::complex<float>, Packet2cf>(from, stride);
225 }
226 template <>
228 pgather_partial<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride, const Index n) {
229  return pgather_complex_size2<std::complex<float>, Packet2cf>(from, stride, n);
230 }
231 template <typename Scalar, typename Packet>
233  const Index n = 2) {
234  eigen_internal_assert(n <= unpacket_traits<Packet>::size && "number of elements will scatter past end of packet");
235  EIGEN_ALIGN16 Scalar af[2];
236  pstore<Scalar>((Scalar*)af, from);
237  for (Index i = 0; i < n; i++) {
238  to[i * stride] = af[i];
239  }
240 }
241 template <>
242 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
243  const Packet2cf& from,
244  Index stride) {
245  pscatter_complex_size2<std::complex<float>, Packet2cf>(to, from, stride);
246 }
247 template <>
248 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void pscatter_partial<std::complex<float>, Packet2cf>(std::complex<float>* to,
249  const Packet2cf& from,
250  Index stride,
251  const Index n) {
252  pscatter_complex_size2<std::complex<float>, Packet2cf>(to, from, stride, n);
253 }
254 
255 template <>
257  return Packet2cf(a.v + b.v);
258 }
259 template <>
261  return Packet2cf(a.v - b.v);
262 }
263 template <>
265  return Packet2cf(pnegate(a.v));
266 }
267 template <>
269  return Packet2cf(pxor<Packet4f>(a.v, reinterpret_cast<Packet4f>(p4ui_CONJ_XOR)));
270 }
271 
272 template <>
274  return Packet2cf(pand<Packet4f>(a.v, b.v));
275 }
276 template <>
278  return Packet2cf(por<Packet4f>(a.v, b.v));
279 }
280 template <>
282  return Packet2cf(pxor<Packet4f>(a.v, b.v));
283 }
284 template <>
286  return Packet2cf(pandnot<Packet4f>(a.v, b.v));
287 }
288 
289 template <>
290 EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float>* addr) {
291  EIGEN_PPC_PREFETCH(addr);
292 }
293 
294 template <>
295 EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(const Packet2cf& a) {
296  EIGEN_ALIGN16 std::complex<float> res[2];
297  pstore((float*)&res, a.v);
298 
299  return res[0];
300 }
301 
302 template <>
304  Packet4f rev_a;
305  rev_a = vec_sld(a.v, a.v, 8);
306  return Packet2cf(rev_a);
307 }
308 
309 template <>
310 EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a) {
311  Packet4f b;
312  b = vec_sld(a.v, a.v, 8);
313  b = padd<Packet4f>(a.v, b);
314  return pfirst<Packet2cf>(Packet2cf(b));
315 }
316 
317 template <>
319  Packet4f b;
320  Packet2cf prod;
321  b = vec_sld(a.v, a.v, 8);
323 
324  return pfirst<Packet2cf>(prod);
325 }
326 
328 
329 template <>
331  return pdiv_complex(a, b);
332 }
333 
334 template <>
336  return Packet2cf(vec_perm(x.v, x.v, p16uc_COMPLEX32_REV));
337 }
338 
340 #ifdef EIGEN_VECTORIZE_VSX
341  Packet4f tmp = reinterpret_cast<Packet4f>(
342  vec_mergeh(reinterpret_cast<Packet2d>(kernel.packet[0].v), reinterpret_cast<Packet2d>(kernel.packet[1].v)));
343  kernel.packet[1].v = reinterpret_cast<Packet4f>(
344  vec_mergel(reinterpret_cast<Packet2d>(kernel.packet[0].v), reinterpret_cast<Packet2d>(kernel.packet[1].v)));
345 #else
346  Packet4f tmp = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_HI);
347  kernel.packet[1].v = vec_perm(kernel.packet[0].v, kernel.packet[1].v, p16uc_TRANSPOSE64_LO);
348 #endif
349  kernel.packet[0].v = tmp;
350 }
351 
352 template <>
354  Packet4f eq = reinterpret_cast<Packet4f>(vec_cmpeq(a.v, b.v));
355  return Packet2cf(vec_and(eq, vec_perm(eq, eq, p16uc_COMPLEX32_REV)));
356 }
357 
358 #ifdef EIGEN_VECTORIZE_VSX
359 template <>
360 EIGEN_STRONG_INLINE Packet2cf pblend(const Selector<2>& ifPacket, const Packet2cf& thenPacket,
361  const Packet2cf& elsePacket) {
362  Packet2cf result;
363  result.v = reinterpret_cast<Packet4f>(
364  pblend<Packet2d>(ifPacket, reinterpret_cast<Packet2d>(thenPacket.v), reinterpret_cast<Packet2d>(elsePacket.v)));
365  return result;
366 }
367 #endif
368 
369 template <>
371  return psqrt_complex<Packet2cf>(a);
372 }
373 
374 template <>
376  return plog_complex<Packet2cf>(a);
377 }
378 
379 template <>
381  return pexp_complex<Packet2cf>(a);
382 }
383 
384 //---------- double ----------
385 #ifdef EIGEN_VECTORIZE_VSX
386 struct Packet1cd {
388  EIGEN_STRONG_INLINE explicit Packet1cd(const Packet2d& a) : v(a) {}
389 
391  Packet2d a_re, a_im, v1, v2;
392 
393  // Permute and multiply the real parts of a and b
394  a_re = vec_perm(a.v, a.v, p16uc_PSET64_HI);
395  // Get the imaginary parts of a
396  a_im = vec_perm(a.v, a.v, p16uc_PSET64_LO);
397  // multiply a_re * b
398  v1 = vec_madd(a_re, b.v, p2d_ZERO);
399  // multiply a_im * b and get the conjugate result
400  v2 = vec_madd(a_im, b.v, p2d_ZERO);
401  v2 = reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(v2), reinterpret_cast<Packet4ui>(v2), 8));
402  v2 = pxor(v2, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR1));
403 
404  return Packet1cd(padd<Packet2d>(v1, v2));
405  }
406 
408  v = pmul(Packet1cd(*this), b).v;
409  return *this;
410  }
411  EIGEN_STRONG_INLINE Packet1cd operator*(const Packet1cd& b) const { return Packet1cd(*this) *= b; }
412 
414  v = padd(v, b.v);
415  return *this;
416  }
417  EIGEN_STRONG_INLINE Packet1cd operator+(const Packet1cd& b) const { return Packet1cd(*this) += b; }
419  v = psub(v, b.v);
420  return *this;
421  }
422  EIGEN_STRONG_INLINE Packet1cd operator-(const Packet1cd& b) const { return Packet1cd(*this) -= b; }
423  EIGEN_STRONG_INLINE Packet1cd operator-(void) const { return Packet1cd(-v); }
424 
425  Packet2d v;
426 };
427 
428 template <>
429 struct packet_traits<std::complex<double> > : default_packet_traits {
430  typedef Packet1cd type;
431  typedef Packet1cd half;
432  typedef Packet2d as_real;
433  enum {
434  Vectorizable = 1,
435  AlignedOnScalar = 0,
436  size = 1,
437 
438  HasAdd = 1,
439  HasSub = 1,
440  HasMul = 1,
441  HasDiv = 1,
442  HasNegate = 1,
443  HasAbs = 0,
444  HasAbs2 = 0,
445  HasMin = 0,
446  HasMax = 0,
447  HasSqrt = 1,
448  HasLog = 1,
449  HasSetLinear = 0
450  };
451 };
452 
453 template <>
454 struct unpacket_traits<Packet1cd> {
455  typedef std::complex<double> type;
456  enum {
457  size = 1,
459  vectorizable = true,
460  masked_load_available = false,
461  masked_store_available = false
462  };
463  typedef Packet1cd half;
464  typedef Packet2d as_real;
465 };
466 
467 template <>
468 EIGEN_STRONG_INLINE Packet1cd pload<Packet1cd>(const std::complex<double>* from) {
469  return Packet1cd(pload<Packet2d>((const double*)from));
470 }
471 template <>
472 EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from) {
473  return Packet1cd(ploadu<Packet2d>((const double*)from));
474 }
475 template <>
476 EIGEN_ALWAYS_INLINE Packet1cd pload_partial<Packet1cd>(const std::complex<double>* from, const Index n,
477  const Index offset) {
478  return Packet1cd(pload_partial<Packet2d>((const double*)from, n * 2, offset * 2));
479 }
480 template <>
481 EIGEN_ALWAYS_INLINE Packet1cd ploadu_partial<Packet1cd>(const std::complex<double>* from, const Index n,
482  const Index offset) {
483  return Packet1cd(ploadu_partial<Packet2d>((const double*)from, n * 2, offset * 2));
484 }
485 template <>
486 EIGEN_STRONG_INLINE void pstore<std::complex<double> >(std::complex<double>* to, const Packet1cd& from) {
487  pstore((double*)to, from.v);
488 }
489 template <>
490 EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double>* to, const Packet1cd& from) {
491  pstoreu((double*)to, from.v);
492 }
493 template <>
494 EIGEN_ALWAYS_INLINE void pstore_partial<std::complex<double> >(std::complex<double>* to, const Packet1cd& from,
495  const Index n, const Index offset) {
496  pstore_partial((double*)to, from.v, n * 2, offset * 2);
497 }
498 template <>
499 EIGEN_ALWAYS_INLINE void pstoreu_partial<std::complex<double> >(std::complex<double>* to, const Packet1cd& from,
500  const Index n, const Index offset) {
501  pstoreu_partial((double*)to, from.v, n * 2, offset * 2);
502 }
503 
504 template <>
505 EIGEN_STRONG_INLINE Packet1cd
506 pset1<Packet1cd>(const std::complex<double>& from) { /* here we really have to use unaligned loads :( */
507  return ploadu<Packet1cd>(&from);
508 }
509 
510 template <>
512 pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index) {
513  return pload<Packet1cd>(from);
514 }
515 template <>
517 pgather_partial<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index, const Index) {
518  return pload<Packet1cd>(from);
519 }
520 template <>
521 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to,
522  const Packet1cd& from, Index) {
523  pstore<std::complex<double> >(to, from);
524 }
525 template <>
526 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void pscatter_partial<std::complex<double>, Packet1cd>(std::complex<double>* to,
527  const Packet1cd& from,
528  Index, const Index) {
529  pstore<std::complex<double> >(to, from);
530 }
531 
532 template <>
533 EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) {
534  return Packet1cd(a.v + b.v);
535 }
536 template <>
537 EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) {
538  return Packet1cd(a.v - b.v);
539 }
540 template <>
541 EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) {
542  return Packet1cd(pnegate(Packet2d(a.v)));
543 }
544 template <>
545 EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a) {
546  return Packet1cd(pxor(a.v, reinterpret_cast<Packet2d>(p2ul_CONJ_XOR2)));
547 }
548 
549 template <>
550 EIGEN_STRONG_INLINE Packet1cd pand<Packet1cd>(const Packet1cd& a, const Packet1cd& b) {
551  return Packet1cd(pand(a.v, b.v));
552 }
553 template <>
554 EIGEN_STRONG_INLINE Packet1cd por<Packet1cd>(const Packet1cd& a, const Packet1cd& b) {
555  return Packet1cd(por(a.v, b.v));
556 }
557 template <>
558 EIGEN_STRONG_INLINE Packet1cd pxor<Packet1cd>(const Packet1cd& a, const Packet1cd& b) {
559  return Packet1cd(pxor(a.v, b.v));
560 }
561 template <>
562 EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b) {
563  return Packet1cd(pandnot(a.v, b.v));
564 }
565 
566 template <>
567 EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(const std::complex<double>* from) {
568  return pset1<Packet1cd>(*from);
569 }
570 
571 template <>
572 EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double>* addr) {
573  EIGEN_PPC_PREFETCH(addr);
574 }
575 
576 template <>
577 EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(const Packet1cd& a) {
578  EIGEN_ALIGN16 std::complex<double> res[1];
579  pstore<std::complex<double> >(res, a);
580 
581  return res[0];
582 }
583 
584 template <>
585 EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) {
586  return a;
587 }
588 
589 template <>
590 EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a) {
591  return pfirst(a);
592 }
593 
594 template <>
595 EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a) {
596  return pfirst(a);
597 }
598 
600 
601 template <>
602 EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b) {
603  return pdiv_complex(a, b);
604 }
605 
606 EIGEN_STRONG_INLINE Packet1cd pcplxflip /*<Packet1cd>*/ (const Packet1cd& x) {
607  return Packet1cd(preverse(Packet2d(x.v)));
608 }
609 
610 EIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet1cd, 2>& kernel) {
611  Packet2d tmp = vec_mergeh(kernel.packet[0].v, kernel.packet[1].v);
612  kernel.packet[1].v = vec_mergel(kernel.packet[0].v, kernel.packet[1].v);
613  kernel.packet[0].v = tmp;
614 }
615 
616 template <>
617 EIGEN_STRONG_INLINE Packet1cd pcmp_eq(const Packet1cd& a, const Packet1cd& b) {
618  // Compare real and imaginary parts of a and b to get the mask vector:
619  // [re(a)==re(b), im(a)==im(b)]
620  Packet2d eq = reinterpret_cast<Packet2d>(vec_cmpeq(a.v, b.v));
621  // Swap real/imag elements in the mask in to get:
622  // [im(a)==im(b), re(a)==re(b)]
623  Packet2d eq_swapped =
624  reinterpret_cast<Packet2d>(vec_sld(reinterpret_cast<Packet4ui>(eq), reinterpret_cast<Packet4ui>(eq), 8));
625  // Return re(a)==re(b) & im(a)==im(b) by computing bitwise AND of eq and eq_swapped
626  return Packet1cd(vec_and(eq, eq_swapped));
627 }
628 
629 template <>
630 EIGEN_STRONG_INLINE Packet1cd psqrt<Packet1cd>(const Packet1cd& a) {
631  return psqrt_complex<Packet1cd>(a);
632 }
633 
634 template <>
635 EIGEN_STRONG_INLINE Packet1cd plog<Packet1cd>(const Packet1cd& a) {
636  return plog_complex<Packet1cd>(a);
637 }
638 
639 #endif // __VSX__
640 } // end namespace internal
641 
642 } // end namespace Eigen
643 
644 #endif // EIGEN_COMPLEX32_ALTIVEC_H
#define EIGEN_PPC_PREFETCH(ADDR)
Definition: AltiVec/PacketMath.h:154
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
#define EIGEN_ALIGN16
Definition: ConfigureVectorization.h:142
#define EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(PACKET_CPLX, PACKET_REAL)
Definition: ConjHelper.h:14
#define EIGEN_ALWAYS_INLINE
Definition: Macros.h:845
#define eigen_internal_assert(x)
Definition: Macros.h:916
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Map< RowVectorXf > v2(M2.data(), M2.size())
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
@ Aligned16
Definition: Constants.h:237
const Scalar * a
Definition: level2_cplx_impl.h:32
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
EIGEN_ALWAYS_INLINE Packet4f pload_partial< Packet4f >(const float *from, const Index n, const Index offset)
Definition: AltiVec/PacketMath.h:593
EIGEN_STRONG_INLINE Packet4f pandnot< Packet4f >(const Packet4f &a, const Packet4f &b)
Definition: AltiVec/PacketMath.h:1465
__m128d Packet2d
Definition: LSX/PacketMath.h:36
static Packet2ul p2ul_CONJ_XOR2
Definition: ZVector/Complex.h:28
EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf &a)
Definition: AltiVec/Complex.h:268
EIGEN_STRONG_INLINE std::complex< float > predux_mul< Packet2cf >(const Packet2cf &a)
Definition: AltiVec/Complex.h:318
EIGEN_STRONG_INLINE std::complex< float > predux< Packet2cf >(const Packet2cf &a)
Definition: AltiVec/Complex.h:310
EIGEN_DEVICE_FUNC void pstore_partial(Scalar *to, const Packet &from, const Index n, const Index offset=0)
Definition: GenericPacketMath.h:899
EIGEN_DEVICE_FUNC Packet padd(const Packet &a, const Packet &b)
Definition: GenericPacketMath.h:318
EIGEN_STRONG_INLINE Packet2d padd< Packet2d >(const Packet2d &a, const Packet2d &b)
Definition: LSX/PacketMath.h:605
EIGEN_STRONG_INLINE Packet2cf psqrt< Packet2cf >(const Packet2cf &a)
Definition: AltiVec/Complex.h:370
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet pgather_complex_size2(const Scalar *from, Index stride, const Index n=2)
Definition: AltiVec/Complex.h:212
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void pscatter_complex_size2(Scalar *to, const Packet &from, Index stride, const Index n=2)
Definition: AltiVec/Complex.h:232
EIGEN_STRONG_INLINE Packet4f padd< Packet4f >(const Packet4f &a, const Packet4f &b)
Definition: AltiVec/PacketMath.h:1066
EIGEN_STRONG_INLINE std::complex< double > predux_mul< Packet1cd >(const Packet1cd &a)
Definition: LSX/Complex.h:420
EIGEN_STRONG_INLINE Packet2cf pload2(const std::complex< float > &from0, const std::complex< float > &from1)
Definition: AltiVec/Complex.h:185
EIGEN_STRONG_INLINE Packet2cf pandnot< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:285
EIGEN_STRONG_INLINE Packet1cd psqrt< Packet1cd >(const Packet1cd &a)
Definition: LSX/Complex.h:462
EIGEN_STRONG_INLINE void ptranspose(PacketBlock< Packet2cf, 2 > &kernel)
Definition: AltiVec/Complex.h:339
EIGEN_STRONG_INLINE Packet1cd plog< Packet1cd >(const Packet1cd &a)
Definition: LSX/Complex.h:472
EIGEN_STRONG_INLINE Packet2cf ploaddup< Packet2cf >(const std::complex< float > *from)
Definition: AltiVec/Complex.h:162
static Packet16uc p16uc_TRANSPOSE64_LO
Definition: AltiVec/PacketMath.h:145
EIGEN_STRONG_INLINE Packet2cf pmul< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: LSX/Complex.h:95
EIGEN_STRONG_INLINE Packet4f por< Packet4f >(const Packet4f &a, const Packet4f &b)
Definition: AltiVec/PacketMath.h:1427
static Packet16uc p16uc_PSET32_WEVEN
Definition: AltiVec/PacketMath.h:132
EIGEN_STRONG_INLINE Packet4i pblend(const Selector< 4 > &ifPacket, const Packet4i &thenPacket, const Packet4i &elsePacket)
Definition: AltiVec/PacketMath.h:3075
EIGEN_STRONG_INLINE std::complex< float > pfirst< Packet2cf >(const Packet2cf &a)
Definition: AltiVec/Complex.h:295
EIGEN_STRONG_INLINE Packet4f pload< Packet4f >(const float *from)
Definition: AltiVec/PacketMath.h:492
EIGEN_STRONG_INLINE Packet1cd ploadu< Packet1cd >(const std::complex< double > *from)
Definition: LSX/Complex.h:373
EIGEN_STRONG_INLINE Packet2cf por< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:277
EIGEN_STRONG_INLINE Packet8h por(const Packet8h &a, const Packet8h &b)
Definition: AVX/PacketMath.h:2309
EIGEN_STRONG_INLINE Packet2cf pset1< Packet2cf >(const std::complex< float > &from)
Definition: AltiVec/Complex.h:125
__vector unsigned int Packet4ui
Definition: AltiVec/PacketMath.h:35
EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf &a)
Definition: AltiVec/Complex.h:303
static Packet4ui p4ui_CONJ_XOR
Definition: AltiVec/Complex.h:21
EIGEN_STRONG_INLINE Packet2cf pcplxflip(const Packet2cf &x)
Definition: LSX/Complex.h:218
EIGEN_STRONG_INLINE Packet4cf pmul(const Packet4cf &a, const Packet4cf &b)
Definition: AVX/Complex.h:88
EIGEN_ALWAYS_INLINE Packet2cf pload_partial< Packet2cf >(const std::complex< float > *from, const Index n, const Index offset)
Definition: AltiVec/Complex.h:152
EIGEN_STRONG_INLINE Packet8h pandnot(const Packet8h &a, const Packet8h &b)
Definition: AVX/PacketMath.h:2323
static Packet2ul p2ul_CONJ_XOR1
Definition: ZVector/Complex.h:26
EIGEN_STRONG_INLINE Packet2d pload< Packet2d >(const double *from)
Definition: LSX/PacketMath.h:1407
EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pdiv_complex(const Packet &x, const Packet &y)
Definition: GenericPacketMathFunctions.h:1318
EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf &a)
Definition: AltiVec/Complex.h:264
EIGEN_STRONG_INLINE Packet1cd pxor< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Definition: LSX/Complex.h:355
EIGEN_STRONG_INLINE Packet2cf pdiv< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:330
EIGEN_DEVICE_FUNC void pstoreu_partial(Scalar *to, const Packet &from, const Index n, const Index offset=0)
Definition: GenericPacketMath.h:917
static Packet4f p4f_MZERO
Definition: AltiVec/PacketMath.h:81
EIGEN_STRONG_INLINE Packet1cd padd< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Definition: LSX/Complex.h:305
EIGEN_STRONG_INLINE Packet2cf ploadu< Packet2cf >(const std::complex< float > *from)
Definition: AltiVec/Complex.h:148
EIGEN_STRONG_INLINE Packet1cd ploaddup< Packet1cd >(const std::complex< double > *from)
Definition: LSX/Complex.h:383
EIGEN_STRONG_INLINE Packet2cf pload< Packet2cf >(const std::complex< float > *from)
Definition: AltiVec/Complex.h:144
EIGEN_STRONG_INLINE bfloat16 pfirst(const Packet8bf &a)
Definition: AltiVec/PacketMath.h:2418
EIGEN_STRONG_INLINE std::complex< double > predux< Packet1cd >(const Packet1cd &a)
Definition: LSX/Complex.h:415
EIGEN_DEVICE_FUNC void pstore(Scalar *to, const Packet &from)
Definition: GenericPacketMath.h:891
static Packet16uc p16uc_PSET64_HI
Definition: AltiVec/PacketMath.h:139
EIGEN_STRONG_INLINE Packet2d ploadu< Packet2d >(const double *from)
Definition: LSX/PacketMath.h:1448
EIGEN_STRONG_INLINE Packet4f pxor< Packet4f >(const Packet4f &a, const Packet4f &b)
Definition: AltiVec/PacketMath.h:1448
EIGEN_STRONG_INLINE Packet1cd pload< Packet1cd >(const std::complex< double > *from)
Definition: LSX/Complex.h:369
EIGEN_STRONG_INLINE Packet2cf pcplxflip< Packet2cf >(const Packet2cf &x)
Definition: AltiVec/Complex.h:335
EIGEN_STRONG_INLINE Packet1cd pand< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Definition: LSX/Complex.h:343
EIGEN_STRONG_INLINE Packet2cf pand< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:273
EIGEN_STRONG_INLINE Packet2cf pcmp_eq(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:353
EIGEN_STRONG_INLINE Packet2cf pexp< Packet2cf >(const Packet2cf &a)
Definition: AltiVec/Complex.h:380
EIGEN_STRONG_INLINE Packet1cd pandnot< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Definition: LSX/Complex.h:361
EIGEN_DEVICE_FUNC void pstoreu(Scalar *to, const Packet &from)
Definition: GenericPacketMath.h:911
EIGEN_STRONG_INLINE Packet8h pand(const Packet8h &a, const Packet8h &b)
Definition: AVX/PacketMath.h:2319
EIGEN_STRONG_INLINE Packet8h pxor(const Packet8h &a, const Packet8h &b)
Definition: AVX/PacketMath.h:2315
EIGEN_STRONG_INLINE Packet2cf pxor< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:281
EIGEN_STRONG_INLINE Packet4f ploadu< Packet4f >(const float *from)
Definition: AltiVec/PacketMath.h:1533
EIGEN_STRONG_INLINE Packet2cf psub< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:260
EIGEN_ALWAYS_INLINE Packet2cf pload_ignore< Packet2cf >(const std::complex< float > *from)
Definition: AltiVec/Complex.h:205
EIGEN_ALWAYS_INLINE Packet4f ploadu_partial< Packet4f >(const float *from, const Index n, const Index offset)
Definition: AltiVec/PacketMath.h:1600
EIGEN_STRONG_INLINE Packet4f pand< Packet4f >(const Packet4f &a, const Packet4f &b)
Definition: AltiVec/PacketMath.h:1406
static Packet16uc p16uc_PSET32_WODD
Definition: AltiVec/PacketMath.h:129
EIGEN_DEVICE_FUNC Packet psub(const Packet &a, const Packet &b)
Definition: GenericPacketMath.h:337
static Packet16uc p16uc_PSET64_LO
Definition: AltiVec/PacketMath.h:141
EIGEN_STRONG_INLINE Packet2cf plog< Packet2cf >(const Packet2cf &a)
Definition: AltiVec/Complex.h:375
static Packet16uc p16uc_COMPLEX32_REV
Definition: AltiVec/PacketMath.h:148
EIGEN_STRONG_INLINE Packet2cf padd< Packet2cf >(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:256
EIGEN_STRONG_INLINE Packet1cd por< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Definition: LSX/Complex.h:349
__vector float Packet4f
Definition: AltiVec/PacketMath.h:33
EIGEN_ALWAYS_INLINE Packet2cf ploadu_partial< Packet2cf >(const std::complex< float > *from, const Index n, const Index offset)
Definition: AltiVec/Complex.h:157
EIGEN_STRONG_INLINE Packet1cd pset1< Packet1cd >(const std::complex< double > &from)
Definition: LSX/Complex.h:378
EIGEN_STRONG_INLINE std::complex< double > pfirst< Packet1cd >(const Packet1cd &a)
Definition: LSX/Complex.h:403
EIGEN_STRONG_INLINE Packet1cd pdiv< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Definition: LSX/Complex.h:427
eigen_packet_wrapper< __m128i, 7 > Packet2ul
Definition: LSX/PacketMath.h:45
EIGEN_STRONG_INLINE Packet1cd psub< Packet1cd >(const Packet1cd &a, const Packet1cd &b)
Definition: LSX/Complex.h:309
static Packet16uc p16uc_TRANSPOSE64_HI
Definition: AltiVec/PacketMath.h:143
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const Product< Lhs, Rhs > prod(const Lhs &lhs, const Rhs &rhs)
Definition: evaluators.cpp:7
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28
EIGEN_STRONG_INLINE Packet1cd operator-(void) const
Definition: MSA/Complex.h:379
EIGEN_STRONG_INLINE Packet1cd & operator+=(const Packet1cd &b)
Definition: MSA/Complex.h:361
EIGEN_STRONG_INLINE Packet1cd operator+(const Packet1cd &b) const
Definition: MSA/Complex.h:365
EIGEN_STRONG_INLINE Packet1cd & operator*=(const Packet1cd &b)
Definition: MSA/Complex.h:341
EIGEN_STRONG_INLINE Packet1cd()
Definition: LSX/Complex.h:261
Packet2d v
Definition: LSX/Complex.h:263
EIGEN_STRONG_INLINE Packet1cd & operator-=(const Packet1cd &b)
Definition: MSA/Complex.h:366
EIGEN_STRONG_INLINE Packet1cd operator*(const Packet1cd &b) const
Definition: MSA/Complex.h:360
Definition: AltiVec/Complex.h:38
EIGEN_STRONG_INLINE Packet2cf & operator+=(const Packet2cf &b)
Definition: AltiVec/Complex.h:66
EIGEN_STRONG_INLINE Packet2cf & operator*=(const Packet2cf &b)
Definition: AltiVec/Complex.h:60
Packet4f v
Definition: AltiVec/Complex.h:78
EIGEN_STRONG_INLINE Packet2cf operator*(const Packet2cf &b) const
Definition: AltiVec/Complex.h:64
EIGEN_STRONG_INLINE Packet2cf operator-(void) const
Definition: AltiVec/Complex.h:76
EIGEN_STRONG_INLINE Packet2cf()
Definition: AltiVec/Complex.h:39
EIGEN_STRONG_INLINE Packet2cf operator-(const Packet2cf &b) const
Definition: AltiVec/Complex.h:75
EIGEN_STRONG_INLINE Packet2cf(const Packet4f &a)
Definition: AltiVec/Complex.h:40
EIGEN_STRONG_INLINE Packet2cf & operator-=(const Packet2cf &b)
Definition: AltiVec/Complex.h:71
EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf &a, const Packet2cf &b)
Definition: AltiVec/Complex.h:42
EIGEN_STRONG_INLINE Packet2cf operator+(const Packet2cf &b) const
Definition: AltiVec/Complex.h:70
__m256 v
Definition: AVX/Complex.h:24
Definition: GenericPacketMath.h:1407
Packet packet[N]
Definition: GenericPacketMath.h:1408
Definition: GenericPacketMath.h:45
@ HasBlend
Definition: GenericPacketMath.h:66
@ HasExp
Definition: GenericPacketMath.h:75
@ HasSqrt
Definition: GenericPacketMath.h:73
@ HasLog
Definition: GenericPacketMath.h:77
@ HasDiv
Definition: GenericPacketMath.h:71
Packet2cf half
Definition: AltiVec/Complex.h:84
Packet2cf type
Definition: AltiVec/Complex.h:83
Packet4f as_real
Definition: AltiVec/Complex.h:85
Definition: GenericPacketMath.h:108
T type
Definition: GenericPacketMath.h:109
@ size
Definition: GenericPacketMath.h:113
@ AlignedOnScalar
Definition: GenericPacketMath.h:114
@ Vectorizable
Definition: GenericPacketMath.h:112
T half
Definition: GenericPacketMath.h:110
@ HasSub
Definition: GenericPacketMath.h:118
@ HasMax
Definition: GenericPacketMath.h:124
@ HasNegate
Definition: GenericPacketMath.h:120
@ HasMul
Definition: GenericPacketMath.h:119
@ HasAdd
Definition: GenericPacketMath.h:117
@ HasSetLinear
Definition: GenericPacketMath.h:126
@ HasMin
Definition: GenericPacketMath.h:123
@ HasAbs2
Definition: GenericPacketMath.h:122
@ HasAbs
Definition: GenericPacketMath.h:121
std::complex< float > type
Definition: AltiVec/Complex.h:112
Packet4f as_real
Definition: AltiVec/Complex.h:121
Packet2cf half
Definition: AltiVec/Complex.h:120
Definition: GenericPacketMath.h:134
T type
Definition: GenericPacketMath.h:135
T half
Definition: GenericPacketMath.h:136
@ masked_load_available
Definition: GenericPacketMath.h:142
@ size
Definition: GenericPacketMath.h:139
@ masked_store_available
Definition: GenericPacketMath.h:143
@ vectorizable
Definition: GenericPacketMath.h:141
@ alignment
Definition: GenericPacketMath.h:140
Definition: datatypes.h:12
Definition: ZVector/PacketMath.h:50