Eigen  3.3.3
Complex.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 // Copyright (C) 2010 Konstantinos Margaritis <markos@freevec.org>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00010 
00011 #ifndef EIGEN_COMPLEX_NEON_H
00012 #define EIGEN_COMPLEX_NEON_H
00013 
00014 namespace Eigen {
00015 
00016 namespace internal {
00017 
00018 inline uint32x4_t p4ui_CONJ_XOR() {
00019 // See bug 1325, clang fails to call vld1q_u64.
00020 #if EIGEN_COMP_CLANG
00021   uint32x4_t ret = { 0x00000000, 0x80000000, 0x00000000, 0x80000000 };
00022   return ret;
00023 #else
00024   static const uint32_t conj_XOR_DATA[] = { 0x00000000, 0x80000000, 0x00000000, 0x80000000 };
00025   return vld1q_u32( conj_XOR_DATA );
00026 #endif
00027 }
00028 
00029 inline uint32x2_t p2ui_CONJ_XOR() {
00030   static const uint32_t conj_XOR_DATA[] = { 0x00000000, 0x80000000 };
00031   return vld1_u32( conj_XOR_DATA );
00032 }
00033 
00034 //---------- float ----------
00035 struct Packet2cf
00036 {
00037   EIGEN_STRONG_INLINE Packet2cf() {}
00038   EIGEN_STRONG_INLINE explicit Packet2cf(const Packet4f& a) : v(a) {}
00039   Packet4f  v;
00040 };
00041 
00042 template<> struct packet_traits<std::complex<float> >  : default_packet_traits
00043 {
00044   typedef Packet2cf type;
00045   typedef Packet2cf half;
00046   enum {
00047     Vectorizable = 1,
00048     AlignedOnScalar = 1,
00049     size = 2,
00050     HasHalfPacket = 0,
00051 
00052     HasAdd    = 1,
00053     HasSub    = 1,
00054     HasMul    = 1,
00055     HasDiv    = 1,
00056     HasNegate = 1,
00057     HasAbs    = 0,
00058     HasAbs2   = 0,
00059     HasMin    = 0,
00060     HasMax    = 0,
00061     HasSetLinear = 0
00062   };
00063 };
00064 
00065 template<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2, alignment=Aligned16}; typedef Packet2cf half; };
00066 
00067 template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>&  from)
00068 {
00069   float32x2_t r64;
00070   r64 = vld1_f32((float *)&from);
00071 
00072   return Packet2cf(vcombine_f32(r64, r64));
00073 }
00074 
00075 template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(padd<Packet4f>(a.v,b.v)); }
00076 template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(psub<Packet4f>(a.v,b.v)); }
00077 template<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a) { return Packet2cf(pnegate<Packet4f>(a.v)); }
00078 template<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a)
00079 {
00080   Packet4ui b = vreinterpretq_u32_f32(a.v);
00081   return Packet2cf(vreinterpretq_f32_u32(veorq_u32(b, p4ui_CONJ_XOR())));
00082 }
00083 
00084 template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00085 {
00086   Packet4f v1, v2;
00087 
00088   // Get the real values of a | a1_re | a1_re | a2_re | a2_re |
00089   v1 = vcombine_f32(vdup_lane_f32(vget_low_f32(a.v), 0), vdup_lane_f32(vget_high_f32(a.v), 0));
00090   // Get the imag values of a | a1_im | a1_im | a2_im | a2_im |
00091   v2 = vcombine_f32(vdup_lane_f32(vget_low_f32(a.v), 1), vdup_lane_f32(vget_high_f32(a.v), 1));
00092   // Multiply the real a with b
00093   v1 = vmulq_f32(v1, b.v);
00094   // Multiply the imag a with b
00095   v2 = vmulq_f32(v2, b.v);
00096   // Conjugate v2 
00097   v2 = vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(v2), p4ui_CONJ_XOR()));
00098   // Swap real/imag elements in v2.
00099   v2 = vrev64q_f32(v2);
00100   // Add and return the result
00101   return Packet2cf(vaddq_f32(v1, v2));
00102 }
00103 
00104 template<> EIGEN_STRONG_INLINE Packet2cf pand   <Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00105 {
00106   return Packet2cf(vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));
00107 }
00108 template<> EIGEN_STRONG_INLINE Packet2cf por    <Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00109 {
00110   return Packet2cf(vreinterpretq_f32_u32(vorrq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));
00111 }
00112 template<> EIGEN_STRONG_INLINE Packet2cf pxor   <Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00113 {
00114   return Packet2cf(vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));
00115 }
00116 template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00117 {
00118   return Packet2cf(vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(a.v),vreinterpretq_u32_f32(b.v))));
00119 }
00120 
00121 template<> EIGEN_STRONG_INLINE Packet2cf pload<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload<Packet4f>((const float*)from)); }
00122 template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu<Packet4f>((const float*)from)); }
00123 
00124 template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>* from) { return pset1<Packet2cf>(*from); }
00125 
00126 template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); }
00127 template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); }
00128 
00129 template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride)
00130 {
00131   Packet4f res = pset1<Packet4f>(0.f);
00132   res = vsetq_lane_f32(std::real(from[0*stride]), res, 0);
00133   res = vsetq_lane_f32(std::imag(from[0*stride]), res, 1);
00134   res = vsetq_lane_f32(std::real(from[1*stride]), res, 2);
00135   res = vsetq_lane_f32(std::imag(from[1*stride]), res, 3);
00136   return Packet2cf(res);
00137 }
00138 
00139 template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride)
00140 {
00141   to[stride*0] = std::complex<float>(vgetq_lane_f32(from.v, 0), vgetq_lane_f32(from.v, 1));
00142   to[stride*1] = std::complex<float>(vgetq_lane_f32(from.v, 2), vgetq_lane_f32(from.v, 3));
00143 }
00144 
00145 template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> *   addr) { EIGEN_ARM_PREFETCH((float *)addr); }
00146 
00147 template<> EIGEN_STRONG_INLINE std::complex<float>  pfirst<Packet2cf>(const Packet2cf& a)
00148 {
00149   std::complex<float> EIGEN_ALIGN16 x[2];
00150   vst1q_f32((float *)x, a.v);
00151   return x[0];
00152 }
00153 
00154 template<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a)
00155 {
00156   float32x2_t a_lo, a_hi;
00157   Packet4f a_r128;
00158 
00159   a_lo = vget_low_f32(a.v);
00160   a_hi = vget_high_f32(a.v);
00161   a_r128 = vcombine_f32(a_hi, a_lo);
00162 
00163   return Packet2cf(a_r128);
00164 }
00165 
00166 template<> EIGEN_STRONG_INLINE Packet2cf pcplxflip<Packet2cf>(const Packet2cf& a)
00167 {
00168   return Packet2cf(vrev64q_f32(a.v));
00169 }
00170 
00171 template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a)
00172 {
00173   float32x2_t a1, a2;
00174   std::complex<float> s;
00175 
00176   a1 = vget_low_f32(a.v);
00177   a2 = vget_high_f32(a.v);
00178   a2 = vadd_f32(a1, a2);
00179   vst1_f32((float *)&s, a2);
00180 
00181   return s;
00182 }
00183 
00184 template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs)
00185 {
00186   Packet4f sum1, sum2, sum;
00187 
00188   // Add the first two 64-bit float32x2_t of vecs[0]
00189   sum1 = vcombine_f32(vget_low_f32(vecs[0].v), vget_low_f32(vecs[1].v));
00190   sum2 = vcombine_f32(vget_high_f32(vecs[0].v), vget_high_f32(vecs[1].v));
00191   sum = vaddq_f32(sum1, sum2);
00192 
00193   return Packet2cf(sum);
00194 }
00195 
00196 template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a)
00197 {
00198   float32x2_t a1, a2, v1, v2, prod;
00199   std::complex<float> s;
00200 
00201   a1 = vget_low_f32(a.v);
00202   a2 = vget_high_f32(a.v);
00203    // Get the real values of a | a1_re | a1_re | a2_re | a2_re |
00204   v1 = vdup_lane_f32(a1, 0);
00205   // Get the real values of a | a1_im | a1_im | a2_im | a2_im |
00206   v2 = vdup_lane_f32(a1, 1);
00207   // Multiply the real a with b
00208   v1 = vmul_f32(v1, a2);
00209   // Multiply the imag a with b
00210   v2 = vmul_f32(v2, a2);
00211   // Conjugate v2 
00212   v2 = vreinterpret_f32_u32(veor_u32(vreinterpret_u32_f32(v2), p2ui_CONJ_XOR()));
00213   // Swap real/imag elements in v2.
00214   v2 = vrev64_f32(v2);
00215   // Add v1, v2
00216   prod = vadd_f32(v1, v2);
00217 
00218   vst1_f32((float *)&s, prod);
00219 
00220   return s;
00221 }
00222 
00223 template<int Offset>
00224 struct palign_impl<Offset,Packet2cf>
00225 {
00226   EIGEN_STRONG_INLINE static void run(Packet2cf& first, const Packet2cf& second)
00227   {
00228     if (Offset==1)
00229     {
00230       first.v = vextq_f32(first.v, second.v, 2);
00231     }
00232   }
00233 };
00234 
00235 template<> struct conj_helper<Packet2cf, Packet2cf, false,true>
00236 {
00237   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const
00238   { return padd(pmul(x,y),c); }
00239 
00240   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const
00241   {
00242     return internal::pmul(a, pconj(b));
00243   }
00244 };
00245 
00246 template<> struct conj_helper<Packet2cf, Packet2cf, true,false>
00247 {
00248   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const
00249   { return padd(pmul(x,y),c); }
00250 
00251   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const
00252   {
00253     return internal::pmul(pconj(a), b);
00254   }
00255 };
00256 
00257 template<> struct conj_helper<Packet2cf, Packet2cf, true,true>
00258 {
00259   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const
00260   { return padd(pmul(x,y),c); }
00261 
00262   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const
00263   {
00264     return pconj(internal::pmul(a, b));
00265   }
00266 };
00267 
00268 template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00269 {
00270   // TODO optimize it for NEON
00271   Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b);
00272   Packet4f s, rev_s;
00273 
00274   // this computes the norm
00275   s = vmulq_f32(b.v, b.v);
00276   rev_s = vrev64q_f32(s);
00277 
00278   return Packet2cf(pdiv(res.v, vaddq_f32(s,rev_s)));
00279 }
00280 
00281 EIGEN_DEVICE_FUNC inline void
00282 ptranspose(PacketBlock<Packet2cf,2>& kernel) {
00283   Packet4f tmp = vcombine_f32(vget_high_f32(kernel.packet[0].v), vget_high_f32(kernel.packet[1].v));
00284   kernel.packet[0].v = vcombine_f32(vget_low_f32(kernel.packet[0].v), vget_low_f32(kernel.packet[1].v));
00285   kernel.packet[1].v = tmp;
00286 }
00287 
00288 //---------- double ----------
00289 #if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG
00290 
00291 // See bug 1325, clang fails to call vld1q_u64.
00292 #if EIGEN_COMP_CLANG
00293   static uint64x2_t p2ul_CONJ_XOR = {0x0, 0x8000000000000000};
00294 #else
00295   const uint64_t  p2ul_conj_XOR_DATA[] = { 0x0, 0x8000000000000000 };
00296   static uint64x2_t p2ul_CONJ_XOR = vld1q_u64( p2ul_conj_XOR_DATA );
00297 #endif
00298 
00299 struct Packet1cd
00300 {
00301   EIGEN_STRONG_INLINE Packet1cd() {}
00302   EIGEN_STRONG_INLINE explicit Packet1cd(const Packet2d& a) : v(a) {}
00303   Packet2d v;
00304 };
00305 
00306 template<> struct packet_traits<std::complex<double> >  : default_packet_traits
00307 {
00308   typedef Packet1cd type;
00309   typedef Packet1cd half;
00310   enum {
00311     Vectorizable = 1,
00312     AlignedOnScalar = 0,
00313     size = 1,
00314     HasHalfPacket = 0,
00315 
00316     HasAdd    = 1,
00317     HasSub    = 1,
00318     HasMul    = 1,
00319     HasDiv    = 1,
00320     HasNegate = 1,
00321     HasAbs    = 0,
00322     HasAbs2   = 0,
00323     HasMin    = 0,
00324     HasMax    = 0,
00325     HasSetLinear = 0
00326   };
00327 };
00328 
00329 template<> struct unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1, alignment=Aligned16}; typedef Packet1cd half; };
00330 
00331 template<> EIGEN_STRONG_INLINE Packet1cd pload<Packet1cd>(const std::complex<double>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet1cd(pload<Packet2d>((const double*)from)); }
00332 template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet1cd(ploadu<Packet2d>((const double*)from)); }
00333 
00334 template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>&  from)
00335 { /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); }
00336 
00337 template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(padd<Packet2d>(a.v,b.v)); }
00338 template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(psub<Packet2d>(a.v,b.v)); }
00339 template<> EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { return Packet1cd(pnegate<Packet2d>(a.v)); }
00340 template<> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a) { return Packet1cd(vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(a.v), p2ul_CONJ_XOR))); }
00341 
00342 template<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00343 {
00344   Packet2d v1, v2;
00345 
00346   // Get the real values of a 
00347   v1 = vdupq_lane_f64(vget_low_f64(a.v), 0);
00348   // Get the imag values of a
00349   v2 = vdupq_lane_f64(vget_high_f64(a.v), 0);
00350   // Multiply the real a with b
00351   v1 = vmulq_f64(v1, b.v);
00352   // Multiply the imag a with b
00353   v2 = vmulq_f64(v2, b.v);
00354   // Conjugate v2 
00355   v2 = vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(v2), p2ul_CONJ_XOR));
00356   // Swap real/imag elements in v2.
00357   v2 = preverse<Packet2d>(v2);
00358   // Add and return the result
00359   return Packet1cd(vaddq_f64(v1, v2));
00360 }
00361 
00362 template<> EIGEN_STRONG_INLINE Packet1cd pand   <Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00363 {
00364   return Packet1cd(vreinterpretq_f64_u64(vandq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));
00365 }
00366 template<> EIGEN_STRONG_INLINE Packet1cd por    <Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00367 {
00368   return Packet1cd(vreinterpretq_f64_u64(vorrq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));
00369 }
00370 template<> EIGEN_STRONG_INLINE Packet1cd pxor   <Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00371 {
00372   return Packet1cd(vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));
00373 }
00374 template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00375 {
00376   return Packet1cd(vreinterpretq_f64_u64(vbicq_u64(vreinterpretq_u64_f64(a.v),vreinterpretq_u64_f64(b.v))));
00377 }
00378 
00379 template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(const std::complex<double>* from) { return pset1<Packet1cd>(*from); }
00380 
00381 template<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, from.v); }
00382 template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> *   to, const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, from.v); }
00383 
00384 template<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> *   addr) { EIGEN_ARM_PREFETCH((double *)addr); }
00385 
00386 template<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index stride)
00387 {
00388   Packet2d res = pset1<Packet2d>(0.0);
00389   res = vsetq_lane_f64(std::real(from[0*stride]), res, 0);
00390   res = vsetq_lane_f64(std::imag(from[0*stride]), res, 1);
00391   return Packet1cd(res);
00392 }
00393 
00394 template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, Index stride)
00395 {
00396   to[stride*0] = std::complex<double>(vgetq_lane_f64(from.v, 0), vgetq_lane_f64(from.v, 1));
00397 }
00398 
00399 
00400 template<> EIGEN_STRONG_INLINE std::complex<double>  pfirst<Packet1cd>(const Packet1cd& a)
00401 {
00402   std::complex<double> EIGEN_ALIGN16 res;
00403   pstore<std::complex<double> >(&res, a);
00404 
00405   return res;
00406 }
00407 
00408 template<> EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) { return a; }
00409 
00410 template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a) { return pfirst(a); }
00411 
00412 template<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(const Packet1cd* vecs) { return vecs[0]; }
00413 
00414 template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a) { return pfirst(a); }
00415 
00416 template<int Offset>
00417 struct palign_impl<Offset,Packet1cd>
00418 {
00419   static EIGEN_STRONG_INLINE void run(Packet1cd& /*first*/, const Packet1cd& /*second*/)
00420   {
00421     // FIXME is it sure we never have to align a Packet1cd?
00422     // Even though a std::complex<double> has 16 bytes, it is not necessarily aligned on a 16 bytes boundary...
00423   }
00424 };
00425 
00426 template<> struct conj_helper<Packet1cd, Packet1cd, false,true>
00427 {
00428   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const
00429   { return padd(pmul(x,y),c); }
00430 
00431   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const
00432   {
00433     return internal::pmul(a, pconj(b));
00434   }
00435 };
00436 
00437 template<> struct conj_helper<Packet1cd, Packet1cd, true,false>
00438 {
00439   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const
00440   { return padd(pmul(x,y),c); }
00441 
00442   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const
00443   {
00444     return internal::pmul(pconj(a), b);
00445   }
00446 };
00447 
00448 template<> struct conj_helper<Packet1cd, Packet1cd, true,true>
00449 {
00450   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const
00451   { return padd(pmul(x,y),c); }
00452 
00453   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const
00454   {
00455     return pconj(internal::pmul(a, b));
00456   }
00457 };
00458 
00459 template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00460 {
00461   // TODO optimize it for NEON
00462   Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);
00463   Packet2d s = pmul<Packet2d>(b.v, b.v);
00464   Packet2d rev_s = preverse<Packet2d>(s);
00465 
00466   return Packet1cd(pdiv(res.v, padd<Packet2d>(s,rev_s)));
00467 }
00468 
00469 EIGEN_STRONG_INLINE Packet1cd pcplxflip/*<Packet1cd>*/(const Packet1cd& x)
00470 {
00471   return Packet1cd(preverse(Packet2d(x.v)));
00472 }
00473 
00474 EIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet1cd,2>& kernel)
00475 {
00476   Packet2d tmp = vcombine_f64(vget_high_f64(kernel.packet[0].v), vget_high_f64(kernel.packet[1].v));
00477   kernel.packet[0].v = vcombine_f64(vget_low_f64(kernel.packet[0].v), vget_low_f64(kernel.packet[1].v));
00478   kernel.packet[1].v = tmp;
00479 }
00480 #endif // EIGEN_ARCH_ARM64
00481 
00482 } // end namespace internal
00483 
00484 } // end namespace Eigen
00485 
00486 #endif // EIGEN_COMPLEX_NEON_H
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends