GNU Radio Manual and C++ API Reference  3.7.7
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
volk_32f_x2_divide_32f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012, 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 /*!
24  * \page volk_32f_x2_divide_32f
25  *
26  * \b Overview
27  *
28  * Divides aVector by bVector to produce cVector:
29  *
30  * c[i] = a[i] / b[i]
31  *
32  * <b>Dispatcher Prototype</b>
33  * \code
34  * void volk_32f_x2_divide_32f(float* cVector, const float* aVector, const float* bVector, unsigned int num_points)
35  * \endcode
36  *
37  * \b Inputs
38  * \li aVector: First vector of input points.
39  * \li bVector: Second vector of input points.
40  * \li num_points: The number of values in both input vector.
41  *
42  * \b Outputs
43  * \li cVector: The output vector.
44  *
45  * \b Example
46  * Divide an increasing vector by a decreasing vector
47  * \code
48  * int N = 10;
49  * unsigned int alignment = volk_get_alignment();
50  * float* increasing = (float*)volk_malloc(sizeof(float)*N, alignment);
51  * float* decreasing = (float*)volk_malloc(sizeof(float)*N, alignment);
52  * float* out = (float*)volk_malloc(sizeof(float)*N, alignment);
53  *
54  * for(unsigned int ii = 0; ii < N; ++ii){
55  * increasing[ii] = (float)ii;
56  * decreasing[ii] = 10.f - (float)ii;
57  * }
58  *
59  * volk_32f_x2_divide_32f(out, increasing, decreasing, N);
60  *
61  * for(unsigned int ii = 0; ii < N; ++ii){
62  * printf("out[%u] = %1.2f\n", ii, out[ii]);
63  * }
64  *
65  * volk_free(increasing);
66  * volk_free(decreasing);
67  * volk_free(out);
68  * \endcode
69  */
70 
71 #ifndef INCLUDED_volk_32f_x2_divide_32f_a_H
72 #define INCLUDED_volk_32f_x2_divide_32f_a_H
73 
74 #include <inttypes.h>
75 #include <stdio.h>
76 
77 #ifdef LV_HAVE_SSE
78 #include <xmmintrin.h>
79 
80 static inline void
81 volk_32f_x2_divide_32f_a_sse(float* cVector, const float* aVector,
82  const float* bVector, unsigned int num_points)
83 {
84  unsigned int number = 0;
85  const unsigned int quarterPoints = num_points / 4;
86 
87  float* cPtr = cVector;
88  const float* aPtr = aVector;
89  const float* bPtr= bVector;
90 
91  __m128 aVal, bVal, cVal;
92  for(;number < quarterPoints; number++){
93  aVal = _mm_load_ps(aPtr);
94  bVal = _mm_load_ps(bPtr);
95 
96  cVal = _mm_div_ps(aVal, bVal);
97 
98  _mm_store_ps(cPtr,cVal); // Store the results back into the C container
99 
100  aPtr += 4;
101  bPtr += 4;
102  cPtr += 4;
103  }
104 
105  number = quarterPoints * 4;
106  for(;number < num_points; number++){
107  *cPtr++ = (*aPtr++) / (*bPtr++);
108  }
109 }
110 #endif /* LV_HAVE_SSE */
111 
112 
113 #ifdef LV_HAVE_GENERIC
114 
115 static inline void
116 volk_32f_x2_divide_32f_generic(float* cVector, const float* aVector,
117  const float* bVector, unsigned int num_points)
118 {
119  float* cPtr = cVector;
120  const float* aPtr = aVector;
121  const float* bPtr= bVector;
122  unsigned int number = 0;
123 
124  for(number = 0; number < num_points; number++){
125  *cPtr++ = (*aPtr++) / (*bPtr++);
126  }
127 }
128 #endif /* LV_HAVE_GENERIC */
129 
130 
131 #ifdef LV_HAVE_ORC
132 
133 extern void
134 volk_32f_x2_divide_32f_a_orc_impl(float* cVector, const float* aVector,
135  const float* bVector, unsigned int num_points);
136 
137 static inline void
138 volk_32f_x2_divide_32f_u_orc(float* cVector, const float* aVector,
139  const float* bVector, unsigned int num_points)
140 {
141  volk_32f_x2_divide_32f_a_orc_impl(cVector, aVector, bVector, num_points);
142 }
143 #endif /* LV_HAVE_ORC */
144 
145 
146 
147 #endif /* INCLUDED_volk_32f_x2_divide_32f_a_H */