Main MRPT website > C++ reference
MRPT logo

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



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011