GNU Radio Manual and C++ API Reference  3.7.4.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_32fc_x2_multiply_32fc.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32fc_x2_multiply_32fc_u_H
2 #define INCLUDED_volk_32fc_x2_multiply_32fc_u_H
3 
4 #include <inttypes.h>
5 #include <stdio.h>
6 #include <volk/volk_complex.h>
7 #include <float.h>
8 
9 #ifdef LV_HAVE_SSE3
10 #include <pmmintrin.h>
11  /*!
12  \brief Multiplies the two input complex vectors and stores their results in the third vector
13  \param cVector The vector where the results will be stored
14  \param aVector One of the vectors to be multiplied
15  \param bVector One of the vectors to be multiplied
16  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
17  */
18 static inline void volk_32fc_x2_multiply_32fc_u_sse3(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
19  unsigned int number = 0;
20  const unsigned int halfPoints = num_points / 2;
21 
22  __m128 x, y, yl, yh, z, tmp1, tmp2;
23  lv_32fc_t* c = cVector;
24  const lv_32fc_t* a = aVector;
25  const lv_32fc_t* b = bVector;
26 
27  for(;number < halfPoints; number++){
28 
29  x = _mm_loadu_ps((float*)a); // Load the ar + ai, br + bi as ar,ai,br,bi
30  y = _mm_loadu_ps((float*)b); // Load the cr + ci, dr + di as cr,ci,dr,di
31 
32  yl = _mm_moveldup_ps(y); // Load yl with cr,cr,dr,dr
33  yh = _mm_movehdup_ps(y); // Load yh with ci,ci,di,di
34 
35  tmp1 = _mm_mul_ps(x,yl); // tmp1 = ar*cr,ai*cr,br*dr,bi*dr
36 
37  x = _mm_shuffle_ps(x,x,0xB1); // Re-arrange x to be ai,ar,bi,br
38 
39  tmp2 = _mm_mul_ps(x,yh); // tmp2 = ai*ci,ar*ci,bi*di,br*di
40 
41  z = _mm_addsub_ps(tmp1,tmp2); // ar*cr-ai*ci, ai*cr+ar*ci, br*dr-bi*di, bi*dr+br*di
42 
43  _mm_storeu_ps((float*)c,z); // Store the results back into the C container
44 
45  a += 2;
46  b += 2;
47  c += 2;
48  }
49 
50  if((num_points % 2) != 0) {
51  *c = (*a) * (*b);
52  }
53 }
54 #endif /* LV_HAVE_SSE */
55 
56 #ifdef LV_HAVE_GENERIC
57  /*!
58  \brief Multiplies the two input complex vectors and stores their results in the third vector
59  \param cVector The vector where the results will be stored
60  \param aVector One of the vectors to be multiplied
61  \param bVector One of the vectors to be multiplied
62  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
63  */
64 static inline void volk_32fc_x2_multiply_32fc_generic(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
65  lv_32fc_t* cPtr = cVector;
66  const lv_32fc_t* aPtr = aVector;
67  const lv_32fc_t* bPtr= bVector;
68  unsigned int number = 0;
69 
70  for(number = 0; number < num_points; number++){
71  *cPtr++ = (*aPtr++) * (*bPtr++);
72  }
73 }
74 #endif /* LV_HAVE_GENERIC */
75 
76 
77 #endif /* INCLUDED_volk_32fc_x2_multiply_32fc_u_H */
78 #ifndef INCLUDED_volk_32fc_x2_multiply_32fc_a_H
79 #define INCLUDED_volk_32fc_x2_multiply_32fc_a_H
80 
81 #include <inttypes.h>
82 #include <stdio.h>
83 #include <volk/volk_complex.h>
84 #include <float.h>
85 
86 #ifdef LV_HAVE_SSE3
87 #include <pmmintrin.h>
88  /*!
89  \brief Multiplies the two input complex vectors and stores their results in the third vector
90  \param cVector The vector where the results will be stored
91  \param aVector One of the vectors to be multiplied
92  \param bVector One of the vectors to be multiplied
93  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
94  */
95 static inline void volk_32fc_x2_multiply_32fc_a_sse3(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
96  unsigned int number = 0;
97  const unsigned int halfPoints = num_points / 2;
98 
99  __m128 x, y, yl, yh, z, tmp1, tmp2;
100  lv_32fc_t* c = cVector;
101  const lv_32fc_t* a = aVector;
102  const lv_32fc_t* b = bVector;
103  for(;number < halfPoints; number++){
104 
105  x = _mm_load_ps((float*)a); // Load the ar + ai, br + bi as ar,ai,br,bi
106  y = _mm_load_ps((float*)b); // Load the cr + ci, dr + di as cr,ci,dr,di
107 
108  yl = _mm_moveldup_ps(y); // Load yl with cr,cr,dr,dr
109  yh = _mm_movehdup_ps(y); // Load yh with ci,ci,di,di
110 
111  tmp1 = _mm_mul_ps(x,yl); // tmp1 = ar*cr,ai*cr,br*dr,bi*dr
112 
113  x = _mm_shuffle_ps(x,x,0xB1); // Re-arrange x to be ai,ar,bi,br
114 
115  tmp2 = _mm_mul_ps(x,yh); // tmp2 = ai*ci,ar*ci,bi*di,br*di
116 
117  z = _mm_addsub_ps(tmp1,tmp2); // ar*cr-ai*ci, ai*cr+ar*ci, br*dr-bi*di, bi*dr+br*di
118 
119  _mm_store_ps((float*)c,z); // Store the results back into the C container
120 
121  a += 2;
122  b += 2;
123  c += 2;
124  }
125 
126  if((num_points % 2) != 0) {
127  *c = (*a) * (*b);
128  }
129 }
130 #endif /* LV_HAVE_SSE */
131 
132 #ifdef LV_HAVE_GENERIC
133  /*!
134  \brief Multiplies the two input complex vectors and stores their results in the third vector
135  \param cVector The vector where the results will be stored
136  \param aVector One of the vectors to be multiplied
137  \param bVector One of the vectors to be multiplied
138  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
139  */
140 static inline void volk_32fc_x2_multiply_32fc_a_generic(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
141  lv_32fc_t* cPtr = cVector;
142  const lv_32fc_t* aPtr = aVector;
143  const lv_32fc_t* bPtr= bVector;
144  unsigned int number = 0;
145 
146  for(number = 0; number < num_points; number++){
147  *cPtr++ = (*aPtr++) * (*bPtr++);
148  }
149 }
150 #endif /* LV_HAVE_GENERIC */
151 
152 #ifdef LV_HAVE_ORC
153  /*!
154  \brief Multiplies the two input complex vectors and stores their results in the third vector
155  \param cVector The vector where the results will be stored
156  \param aVector One of the vectors to be multiplied
157  \param bVector One of the vectors to be multiplied
158  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
159  */
160 extern void volk_32fc_x2_multiply_32fc_a_orc_impl(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points);
161 static inline void volk_32fc_x2_multiply_32fc_u_orc(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
162  volk_32fc_x2_multiply_32fc_a_orc_impl(cVector, aVector, bVector, num_points);
163 }
164 #endif /* LV_HAVE_ORC */
165 
166 
167 
168 
169 
170 #endif /* INCLUDED_volk_32fc_x2_multiply_32fc_a_H */
float complex lv_32fc_t
Definition: volk_complex.h:56