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