<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>GNU Radio 7f75d35b C++ API: volk_32fc_x2_square_dist_32f_a.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">GNU Radio 7f75d35b C++ API
   
   </div>
   
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('volk__32fc__x2__square__dist__32f__a_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">volk_32fc_x2_square_dist_32f_a.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="volk__32fc__x2__square__dist__32f__a_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef INCLUDED_volk_32fc_x2_square_dist_32f_a_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define INCLUDED_volk_32fc_x2_square_dist_32f_a_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include&lt;<a class="code" href="inttypes_8h.html">inttypes.h</a>&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include&lt;stdio.h&gt;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include&lt;<a class="code" href="volk__complex_8h.html">volk/volk_complex.h</a>&gt;</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="preprocessor">#ifdef LV_HAVE_SSE3</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#include&lt;xmmintrin.h&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include&lt;pmmintrin.h&gt;</span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> volk_32fc_x2_square_dist_32f_a_sse3(<span class="keywordtype">float</span>* target, <a class="code" href="volk__complex_8h.html#ace50e1c8ef539cdeee04bc86f0e99169">lv_32fc_t</a>* src0, <a class="code" href="volk__complex_8h.html#ace50e1c8ef539cdeee04bc86f0e99169">lv_32fc_t</a>* points, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> num_bytes) {
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 
<a name="l00015"></a>00015   __m128 xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
<a name="l00016"></a>00016 
<a name="l00017"></a>00017   <a class="code" href="volk__complex_8h.html#ace50e1c8ef539cdeee04bc86f0e99169">lv_32fc_t</a> diff;
<a name="l00018"></a>00018   <span class="keywordtype">float</span> sq_dist;
<a name="l00019"></a>00019   <span class="keywordtype">int</span> bound = num_bytes &gt;&gt; 5;
<a name="l00020"></a>00020   <span class="keywordtype">int</span> leftovers0 = (num_bytes &gt;&gt; 4) &amp; 1;
<a name="l00021"></a>00021   <span class="keywordtype">int</span> leftovers1 = (num_bytes &gt;&gt; 3) &amp; 1;
<a name="l00022"></a>00022   <span class="keywordtype">int</span> i = 0;
<a name="l00023"></a>00023 
<a name="l00024"></a>00024   xmm1 = _mm_setzero_ps();
<a name="l00025"></a>00025   xmm1 = _mm_loadl_pi(xmm1, (__m64*)src0);
<a name="l00026"></a>00026   xmm2 = _mm_load_ps((<span class="keywordtype">float</span>*)&amp;points[0]);
<a name="l00027"></a>00027   xmm1 = _mm_movelh_ps(xmm1, xmm1);
<a name="l00028"></a>00028   xmm3 = _mm_load_ps((<span class="keywordtype">float</span>*)&amp;points[2]);
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 
<a name="l00031"></a>00031   <span class="keywordflow">for</span>(; i &lt; bound - 1; ++i) {
<a name="l00032"></a>00032     xmm4 = _mm_sub_ps(xmm1, xmm2);
<a name="l00033"></a>00033     xmm5 = _mm_sub_ps(xmm1, xmm3);
<a name="l00034"></a>00034     points += 4;
<a name="l00035"></a>00035     xmm6 = _mm_mul_ps(xmm4, xmm4);
<a name="l00036"></a>00036     xmm7 = _mm_mul_ps(xmm5, xmm5);
<a name="l00037"></a>00037 
<a name="l00038"></a>00038     xmm2 = _mm_load_ps((<span class="keywordtype">float</span>*)&amp;points[0]);
<a name="l00039"></a>00039 
<a name="l00040"></a>00040     xmm4 = _mm_hadd_ps(xmm6, xmm7);
<a name="l00041"></a>00041 
<a name="l00042"></a>00042     xmm3 = _mm_load_ps((<span class="keywordtype">float</span>*)&amp;points[2]);
<a name="l00043"></a>00043 
<a name="l00044"></a>00044     _mm_store_ps(target, xmm4);
<a name="l00045"></a>00045 
<a name="l00046"></a>00046     target += 4;
<a name="l00047"></a>00047 
<a name="l00048"></a>00048   }
<a name="l00049"></a>00049 
<a name="l00050"></a>00050   xmm4 = _mm_sub_ps(xmm1, xmm2);
<a name="l00051"></a>00051   xmm5 = _mm_sub_ps(xmm1, xmm3);
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 
<a name="l00055"></a>00055   points += 4;
<a name="l00056"></a>00056   xmm6 = _mm_mul_ps(xmm4, xmm4);
<a name="l00057"></a>00057   xmm7 = _mm_mul_ps(xmm5, xmm5);
<a name="l00058"></a>00058 
<a name="l00059"></a>00059   xmm4 = _mm_hadd_ps(xmm6, xmm7);
<a name="l00060"></a>00060 
<a name="l00061"></a>00061   _mm_store_ps(target, xmm4);
<a name="l00062"></a>00062 
<a name="l00063"></a>00063   target += 4;
<a name="l00064"></a>00064 
<a name="l00065"></a>00065   <span class="keywordflow">for</span>(i = 0; i &lt; leftovers0; ++i) {
<a name="l00066"></a>00066 
<a name="l00067"></a>00067     xmm2 = _mm_load_ps((<span class="keywordtype">float</span>*)&amp;points[0]);
<a name="l00068"></a>00068 
<a name="l00069"></a>00069     xmm4 = _mm_sub_ps(xmm1, xmm2);
<a name="l00070"></a>00070 
<a name="l00071"></a>00071     points += 2;
<a name="l00072"></a>00072 
<a name="l00073"></a>00073     xmm6 = _mm_mul_ps(xmm4, xmm4);
<a name="l00074"></a>00074 
<a name="l00075"></a>00075     xmm4 = _mm_hadd_ps(xmm6, xmm6);
<a name="l00076"></a>00076 
<a name="l00077"></a>00077     _mm_storeh_pi((__m64*)target, xmm4);
<a name="l00078"></a>00078 
<a name="l00079"></a>00079     target += 2;
<a name="l00080"></a>00080   }
<a name="l00081"></a>00081 
<a name="l00082"></a>00082   <span class="keywordflow">for</span>(i = 0; i &lt; leftovers1; ++i) {
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     diff = src0[0] - points[0];
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     sq_dist = <a class="code" href="volk__complex_8h.html#a9e9cedc79eafa6db42f03878b5a5ba47">lv_creal</a>(diff) * <a class="code" href="volk__complex_8h.html#a9e9cedc79eafa6db42f03878b5a5ba47">lv_creal</a>(diff) + <a class="code" href="volk__complex_8h.html#a1f58129a88c382411b2e8997c8dd89e4">lv_cimag</a>(diff) * <a class="code" href="volk__complex_8h.html#a1f58129a88c382411b2e8997c8dd89e4">lv_cimag</a>(diff);
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     target[0] = sq_dist;
<a name="l00089"></a>00089   }
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 <span class="preprocessor">#endif </span><span class="comment">/*LV_HAVE_SSE3*/</span>
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 <span class="preprocessor">#ifdef LV_HAVE_GENERIC</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> volk_32fc_x2_square_dist_32f_a_generic(<span class="keywordtype">float</span>* target, <a class="code" href="volk__complex_8h.html#ace50e1c8ef539cdeee04bc86f0e99169">lv_32fc_t</a>* src0, <a class="code" href="volk__complex_8h.html#ace50e1c8ef539cdeee04bc86f0e99169">lv_32fc_t</a>* points, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> num_bytes) {
<a name="l00096"></a>00096   <a class="code" href="volk__complex_8h.html#ace50e1c8ef539cdeee04bc86f0e99169">lv_32fc_t</a> diff;
<a name="l00097"></a>00097   <span class="keywordtype">float</span> sq_dist;
<a name="l00098"></a>00098   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0;
<a name="l00099"></a>00099 
<a name="l00100"></a>00100   <span class="keywordflow">for</span>(; i &lt; num_bytes &gt;&gt; 3; ++i) {
<a name="l00101"></a>00101     diff = src0[0] - points[i];
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     sq_dist = <a class="code" href="volk__complex_8h.html#a9e9cedc79eafa6db42f03878b5a5ba47">lv_creal</a>(diff) * <a class="code" href="volk__complex_8h.html#a9e9cedc79eafa6db42f03878b5a5ba47">lv_creal</a>(diff) + <a class="code" href="volk__complex_8h.html#a1f58129a88c382411b2e8997c8dd89e4">lv_cimag</a>(diff) * <a class="code" href="volk__complex_8h.html#a1f58129a88c382411b2e8997c8dd89e4">lv_cimag</a>(diff);
<a name="l00104"></a>00104 
<a name="l00105"></a>00105     target[i] = sq_dist;
<a name="l00106"></a>00106   }
<a name="l00107"></a>00107 }
<a name="l00108"></a>00108 
<a name="l00109"></a>00109 <span class="preprocessor">#endif </span><span class="comment">/*LV_HAVE_GENERIC*/</span>
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 <span class="preprocessor">#endif </span><span class="comment">/*INCLUDED_volk_32fc_x2_square_dist_32f_a_H*/</span>
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="volk__32fc__x2__square__dist__32f__a_8h.html">volk_32fc_x2_square_dist_32f_a.h</a>      </li>

    <li class="footer">Generated on Thu Sep 27 2012 10:49:26 for GNU Radio 7f75d35b C++ API by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
