Complex.h
Go to the documentation of this file.
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 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_COMPLEX_SSE_H
00011 #define EIGEN_COMPLEX_SSE_H
00012 
00013 namespace Eigen {
00014 
00015 namespace internal {
00016 
00017 //---------- float ----------
00018 struct Packet2cf
00019 {
00020   EIGEN_STRONG_INLINE Packet2cf() {}
00021   EIGEN_STRONG_INLINE explicit Packet2cf(const __m128& a) : v(a) {}
00022   __m128  v;
00023 };
00024 
00025 template<> struct packet_traits<std::complex<float> >  : default_packet_traits
00026 {
00027   typedef Packet2cf type;
00028   enum {
00029     Vectorizable = 1,
00030     AlignedOnScalar = 1,
00031     size = 2,
00032 
00033     HasAdd    = 1,
00034     HasSub    = 1,
00035     HasMul    = 1,
00036     HasDiv    = 1,
00037     HasNegate = 1,
00038     HasAbs    = 0,
00039     HasAbs2   = 0,
00040     HasMin    = 0,
00041     HasMax    = 0,
00042     HasSetLinear = 0
00043   };
00044 };
00045 
00046 template<> struct unpacket_traits<Packet2cf> { typedef std::complex<float> type; enum {size=2}; };
00047 
00048 template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_add_ps(a.v,b.v)); }
00049 template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_sub_ps(a.v,b.v)); }
00050 template<> EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf& a)
00051 {
00052   const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000));
00053   return Packet2cf(_mm_xor_ps(a.v,mask));
00054 }
00055 template<> EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf& a)
00056 {
00057   const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
00058   return Packet2cf(_mm_xor_ps(a.v,mask));
00059 }
00060 
00061 template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00062 {
00063   // TODO optimize it for SSE3 and 4
00064   #ifdef EIGEN_VECTORIZE_SSE3
00065   return Packet2cf(_mm_addsub_ps(_mm_mul_ps(_mm_moveldup_ps(a.v), b.v),
00066                                  _mm_mul_ps(_mm_movehdup_ps(a.v),
00067                                             vec4f_swizzle1(b.v, 1, 0, 3, 2))));
00068 //   return Packet2cf(_mm_addsub_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),
00069 //                                  _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
00070 //                                             vec4f_swizzle1(b.v, 1, 0, 3, 2))));
00071   #else
00072   const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x00000000,0x80000000,0x00000000));
00073   return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),
00074                               _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
00075                                                     vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask)));
00076   #endif
00077 }
00078 
00079 template<> EIGEN_STRONG_INLINE Packet2cf pand   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_and_ps(a.v,b.v)); }
00080 template<> EIGEN_STRONG_INLINE Packet2cf por    <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_or_ps(a.v,b.v)); }
00081 template<> EIGEN_STRONG_INLINE Packet2cf pxor   <Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_xor_ps(a.v,b.v)); }
00082 template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(const Packet2cf& a, const Packet2cf& b) { return Packet2cf(_mm_andnot_ps(a.v,b.v)); }
00083 
00084 template<> EIGEN_STRONG_INLINE Packet2cf pload <Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD return Packet2cf(pload<Packet4f>(&real_ref(*from))); }
00085 template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD return Packet2cf(ploadu<Packet4f>(&real_ref(*from))); }
00086 
00087 template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>&  from)
00088 {
00089   Packet2cf res;
00090   #if EIGEN_GNUC_AT_MOST(4,2)
00091   // workaround annoying "may be used uninitialized in this function" warning with gcc 4.2
00092   res.v = _mm_loadl_pi(_mm_set1_ps(0.0f), reinterpret_cast<const __m64*>(&from));
00093   #else
00094   res.v = _mm_loadl_pi(res.v, (const __m64*)&from);
00095   #endif
00096   return Packet2cf(_mm_movelh_ps(res.v,res.v));
00097 }
00098 
00099 template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>* from) { return pset1<Packet2cf>(*from); }
00100 
00101 template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&real_ref(*to), from.v); }
00102 template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> *   to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&real_ref(*to), from.v); }
00103 
00104 template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> *   addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
00105 
00106 template<> EIGEN_STRONG_INLINE std::complex<float>  pfirst<Packet2cf>(const Packet2cf& a)
00107 {
00108   #if EIGEN_GNUC_AT_MOST(4,3)
00109   // Workaround gcc 4.2 ICE - this is not performance wise ideal, but who cares...
00110   // This workaround also fix invalid code generation with gcc 4.3
00111   EIGEN_ALIGN16 std::complex<float> res[2];
00112   _mm_store_ps((float*)res, a.v);
00113   return res[0];
00114   #else
00115   std::complex<float> res;
00116   _mm_storel_pi((__m64*)&res, a.v);
00117   return res;
00118   #endif
00119 }
00120 
00121 template<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a) { return Packet2cf(_mm_castpd_ps(preverse(_mm_castps_pd(a.v)))); }
00122 
00123 template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(const Packet2cf& a)
00124 {
00125   return pfirst(Packet2cf(_mm_add_ps(a.v, _mm_movehl_ps(a.v,a.v))));
00126 }
00127 
00128 template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(const Packet2cf* vecs)
00129 {
00130   return Packet2cf(_mm_add_ps(_mm_movelh_ps(vecs[0].v,vecs[1].v), _mm_movehl_ps(vecs[1].v,vecs[0].v)));
00131 }
00132 
00133 template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(const Packet2cf& a)
00134 {
00135   return pfirst(pmul(a, Packet2cf(_mm_movehl_ps(a.v,a.v))));
00136 }
00137 
00138 template<int Offset>
00139 struct palign_impl<Offset,Packet2cf>
00140 {
00141   static EIGEN_STRONG_INLINE void run(Packet2cf& first, const Packet2cf& second)
00142   {
00143     if (Offset==1)
00144     {
00145       first.v = _mm_movehl_ps(first.v, first.v);
00146       first.v = _mm_movelh_ps(first.v, second.v);
00147     }
00148   }
00149 };
00150 
00151 template<> struct conj_helper<Packet2cf, Packet2cf, false,true>
00152 {
00153   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const
00154   { return padd(pmul(x,y),c); }
00155 
00156   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const
00157   {
00158     #ifdef EIGEN_VECTORIZE_SSE3
00159     return internal::pmul(a, pconj(b));
00160     #else
00161     const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
00162     return Packet2cf(_mm_add_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask),
00163                                 _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
00164                                            vec4f_swizzle1(b.v, 1, 0, 3, 2))));
00165     #endif
00166   }
00167 };
00168 
00169 template<> struct conj_helper<Packet2cf, Packet2cf, true,false>
00170 {
00171   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const
00172   { return padd(pmul(x,y),c); }
00173 
00174   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const
00175   {
00176     #ifdef EIGEN_VECTORIZE_SSE3
00177     return internal::pmul(pconj(a), b);
00178     #else
00179     const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
00180     return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),
00181                                 _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
00182                                                       vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask)));
00183     #endif
00184   }
00185 };
00186 
00187 template<> struct conj_helper<Packet2cf, Packet2cf, true,true>
00188 {
00189   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet2cf& y, const Packet2cf& c) const
00190   { return padd(pmul(x,y),c); }
00191 
00192   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const
00193   {
00194     #ifdef EIGEN_VECTORIZE_SSE3
00195     return pconj(internal::pmul(a, b));
00196     #else
00197     const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
00198     return Packet2cf(_mm_sub_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask),
00199                                 _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
00200                                            vec4f_swizzle1(b.v, 1, 0, 3, 2))));
00201     #endif
00202   }
00203 };
00204 
00205 template<> struct conj_helper<Packet4f, Packet2cf, false,false>
00206 {
00207   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet4f& x, const Packet2cf& y, const Packet2cf& c) const
00208   { return padd(c, pmul(x,y)); }
00209 
00210   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet4f& x, const Packet2cf& y) const
00211   { return Packet2cf(Eigen::internal::pmul(x, y.v)); }
00212 };
00213 
00214 template<> struct conj_helper<Packet2cf, Packet4f, false,false>
00215 {
00216   EIGEN_STRONG_INLINE Packet2cf pmadd(const Packet2cf& x, const Packet4f& y, const Packet2cf& c) const
00217   { return padd(c, pmul(x,y)); }
00218 
00219   EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& x, const Packet4f& y) const
00220   { return Packet2cf(Eigen::internal::pmul(x.v, y)); }
00221 };
00222 
00223 template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(const Packet2cf& a, const Packet2cf& b)
00224 {
00225   // TODO optimize it for SSE3 and 4
00226   Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b);
00227   __m128 s = _mm_mul_ps(b.v,b.v);
00228   return Packet2cf(_mm_div_ps(res.v,_mm_add_ps(s,_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(s), 0xb1)))));
00229 }
00230 
00231 EIGEN_STRONG_INLINE Packet2cf pcplxflip/*<Packet2cf>*/(const Packet2cf& x)
00232 {
00233   return Packet2cf(vec4f_swizzle1(x.v, 1, 0, 3, 2));
00234 }
00235 
00236 
00237 //---------- double ----------
00238 struct Packet1cd
00239 {
00240   EIGEN_STRONG_INLINE Packet1cd() {}
00241   EIGEN_STRONG_INLINE explicit Packet1cd(const __m128d& a) : v(a) {}
00242   __m128d  v;
00243 };
00244 
00245 template<> struct packet_traits<std::complex<double> >  : default_packet_traits
00246 {
00247   typedef Packet1cd type;
00248   enum {
00249     Vectorizable = 1,
00250     AlignedOnScalar = 0,
00251     size = 1,
00252 
00253     HasAdd    = 1,
00254     HasSub    = 1,
00255     HasMul    = 1,
00256     HasDiv    = 1,
00257     HasNegate = 1,
00258     HasAbs    = 0,
00259     HasAbs2   = 0,
00260     HasMin    = 0,
00261     HasMax    = 0,
00262     HasSetLinear = 0
00263   };
00264 };
00265 
00266 template<> struct unpacket_traits<Packet1cd> { typedef std::complex<double> type; enum {size=1}; };
00267 
00268 template<> EIGEN_STRONG_INLINE Packet1cd padd<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_add_pd(a.v,b.v)); }
00269 template<> EIGEN_STRONG_INLINE Packet1cd psub<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_sub_pd(a.v,b.v)); }
00270 template<> EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { return Packet1cd(pnegate(a.v)); }
00271 template<> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a)
00272 {
00273   const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
00274   return Packet1cd(_mm_xor_pd(a.v,mask));
00275 }
00276 
00277 template<> EIGEN_STRONG_INLINE Packet1cd pmul<Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00278 {
00279   // TODO optimize it for SSE3 and 4
00280   #ifdef EIGEN_VECTORIZE_SSE3
00281   return Packet1cd(_mm_addsub_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),
00282                                  _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
00283                                             vec2d_swizzle1(b.v, 1, 0))));
00284   #else
00285   const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0));
00286   return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),
00287                               _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
00288                                                     vec2d_swizzle1(b.v, 1, 0)), mask)));
00289   #endif
00290 }
00291 
00292 template<> EIGEN_STRONG_INLINE Packet1cd pand   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_and_pd(a.v,b.v)); }
00293 template<> EIGEN_STRONG_INLINE Packet1cd por    <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_or_pd(a.v,b.v)); }
00294 template<> EIGEN_STRONG_INLINE Packet1cd pxor   <Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_xor_pd(a.v,b.v)); }
00295 template<> EIGEN_STRONG_INLINE Packet1cd pandnot<Packet1cd>(const Packet1cd& a, const Packet1cd& b) { return Packet1cd(_mm_andnot_pd(a.v,b.v)); }
00296 
00297 // FIXME force unaligned load, this is a temporary fix
00298 template<> EIGEN_STRONG_INLINE Packet1cd pload <Packet1cd>(const std::complex<double>* from)
00299 { EIGEN_DEBUG_ALIGNED_LOAD return Packet1cd(pload<Packet2d>((const double*)from)); }
00300 template<> EIGEN_STRONG_INLINE Packet1cd ploadu<Packet1cd>(const std::complex<double>* from)
00301 { EIGEN_DEBUG_UNALIGNED_LOAD return Packet1cd(ploadu<Packet2d>((const double*)from)); }
00302 template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>&  from)
00303 { /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); }
00304 
00305 template<> EIGEN_STRONG_INLINE Packet1cd ploaddup<Packet1cd>(const std::complex<double>* from) { return pset1<Packet1cd>(*from); }
00306 
00307 // FIXME force unaligned store, this is a temporary fix
00308 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); }
00309 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); }
00310 
00311 template<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> *   addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
00312 
00313 template<> EIGEN_STRONG_INLINE std::complex<double>  pfirst<Packet1cd>(const Packet1cd& a)
00314 {
00315   EIGEN_ALIGN16 double res[2];
00316   _mm_store_pd(res, a.v);
00317   return std::complex<double>(res[0],res[1]);
00318 }
00319 
00320 template<> EIGEN_STRONG_INLINE Packet1cd preverse(const Packet1cd& a) { return a; }
00321 
00322 template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(const Packet1cd& a)
00323 {
00324   return pfirst(a);
00325 }
00326 
00327 template<> EIGEN_STRONG_INLINE Packet1cd preduxp<Packet1cd>(const Packet1cd* vecs)
00328 {
00329   return vecs[0];
00330 }
00331 
00332 template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(const Packet1cd& a)
00333 {
00334   return pfirst(a);
00335 }
00336 
00337 template<int Offset>
00338 struct palign_impl<Offset,Packet1cd>
00339 {
00340   static EIGEN_STRONG_INLINE void run(Packet1cd& /*first*/, const Packet1cd& /*second*/)
00341   {
00342     // FIXME is it sure we never have to align a Packet1cd?
00343     // Even though a std::complex<double> has 16 bytes, it is not necessarily aligned on a 16 bytes boundary...
00344   }
00345 };
00346 
00347 template<> struct conj_helper<Packet1cd, Packet1cd, false,true>
00348 {
00349   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const
00350   { return padd(pmul(x,y),c); }
00351 
00352   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const
00353   {
00354     #ifdef EIGEN_VECTORIZE_SSE3
00355     return internal::pmul(a, pconj(b));
00356     #else
00357     const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
00358     return Packet1cd(_mm_add_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask),
00359                                 _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
00360                                            vec2d_swizzle1(b.v, 1, 0))));
00361     #endif
00362   }
00363 };
00364 
00365 template<> struct conj_helper<Packet1cd, Packet1cd, true,false>
00366 {
00367   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const
00368   { return padd(pmul(x,y),c); }
00369 
00370   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const
00371   {
00372     #ifdef EIGEN_VECTORIZE_SSE3
00373     return internal::pmul(pconj(a), b);
00374     #else
00375     const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
00376     return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),
00377                                 _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
00378                                                       vec2d_swizzle1(b.v, 1, 0)), mask)));
00379     #endif
00380   }
00381 };
00382 
00383 template<> struct conj_helper<Packet1cd, Packet1cd, true,true>
00384 {
00385   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet1cd& y, const Packet1cd& c) const
00386   { return padd(pmul(x,y),c); }
00387 
00388   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const
00389   {
00390     #ifdef EIGEN_VECTORIZE_SSE3
00391     return pconj(internal::pmul(a, b));
00392     #else
00393     const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
00394     return Packet1cd(_mm_sub_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask),
00395                                 _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
00396                                            vec2d_swizzle1(b.v, 1, 0))));
00397     #endif
00398   }
00399 };
00400 
00401 template<> struct conj_helper<Packet2d, Packet1cd, false,false>
00402 {
00403   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet2d& x, const Packet1cd& y, const Packet1cd& c) const
00404   { return padd(c, pmul(x,y)); }
00405 
00406   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet2d& x, const Packet1cd& y) const
00407   { return Packet1cd(Eigen::internal::pmul(x, y.v)); }
00408 };
00409 
00410 template<> struct conj_helper<Packet1cd, Packet2d, false,false>
00411 {
00412   EIGEN_STRONG_INLINE Packet1cd pmadd(const Packet1cd& x, const Packet2d& y, const Packet1cd& c) const
00413   { return padd(c, pmul(x,y)); }
00414 
00415   EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& x, const Packet2d& y) const
00416   { return Packet1cd(Eigen::internal::pmul(x.v, y)); }
00417 };
00418 
00419 template<> EIGEN_STRONG_INLINE Packet1cd pdiv<Packet1cd>(const Packet1cd& a, const Packet1cd& b)
00420 {
00421   // TODO optimize it for SSE3 and 4
00422   Packet1cd res = conj_helper<Packet1cd,Packet1cd,false,true>().pmul(a,b);
00423   __m128d s = _mm_mul_pd(b.v,b.v);
00424   return Packet1cd(_mm_div_pd(res.v, _mm_add_pd(s,_mm_shuffle_pd(s, s, 0x1))));
00425 }
00426 
00427 EIGEN_STRONG_INLINE Packet1cd pcplxflip/*<Packet1cd>*/(const Packet1cd& x)
00428 {
00429   return Packet1cd(preverse(x.v));
00430 }
00431 
00432 } // end namespace internal
00433 
00434 } // end namespace Eigen
00435 
00436 #endif // EIGEN_COMPLEX_SSE_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:10:26