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_conjugate_32fc.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32fc_x2_multiply_conjugate_32fc_u_H
2 #define INCLUDED_volk_32fc_x2_multiply_conjugate_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 vector a by the conjugate of vector b and stores the results in the third vector
13  \param cVector The vector where the results will be stored
14  \param aVector First vector to be multiplied
15  \param bVector Second vector that is conjugated before being 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_conjugate_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  __m128 conjugator = _mm_setr_ps(0, -0.f, 0, -0.f);
28 
29  for(;number < halfPoints; number++){
30 
31  x = _mm_loadu_ps((float*)a); // Load the ar + ai, br + bi as ar,ai,br,bi
32  y = _mm_loadu_ps((float*)b); // Load the cr + ci, dr + di as cr,ci,dr,di
33 
34  y = _mm_xor_ps(y, conjugator); // conjugate y
35 
36  yl = _mm_moveldup_ps(y); // Load yl with cr,cr,dr,dr
37  yh = _mm_movehdup_ps(y); // Load yh with ci,ci,di,di
38 
39  tmp1 = _mm_mul_ps(x,yl); // tmp1 = ar*cr,ai*cr,br*dr,bi*dr
40 
41  x = _mm_shuffle_ps(x,x,0xB1); // Re-arrange x to be ai,ar,bi,br
42 
43  tmp2 = _mm_mul_ps(x,yh); // tmp2 = ai*ci,ar*ci,bi*di,br*di
44 
45  z = _mm_addsub_ps(tmp1,tmp2); // ar*cr-ai*ci, ai*cr+ar*ci, br*dr-bi*di, bi*dr+br*di
46 
47  _mm_storeu_ps((float*)c,z); // Store the results back into the C container
48 
49  a += 2;
50  b += 2;
51  c += 2;
52  }
53 
54  if((num_points % 2) != 0) {
55  *c = (*a) * lv_conj(*b);
56  }
57 }
58 #endif /* LV_HAVE_SSE */
59 
60 #ifdef LV_HAVE_GENERIC
61  /*!
62  \brief Multiplies vector a by the conjugate of vector b and stores the results in the third vector
63  \param cVector The vector where the results will be stored
64  \param aVector First vector to be multiplied
65  \param bVector Second vector that is conjugated before being multiplied
66  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
67  */
68 static inline void volk_32fc_x2_multiply_conjugate_32fc_generic(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
69  lv_32fc_t* cPtr = cVector;
70  const lv_32fc_t* aPtr = aVector;
71  const lv_32fc_t* bPtr= bVector;
72  unsigned int number = 0;
73 
74  for(number = 0; number < num_points; number++){
75  *cPtr++ = (*aPtr++) * lv_conj(*bPtr++);
76  }
77 }
78 #endif /* LV_HAVE_GENERIC */
79 
80 
81 #endif /* INCLUDED_volk_32fc_x2_multiply_conjugate_32fc_u_H */
82 #ifndef INCLUDED_volk_32fc_x2_multiply_conjugate_32fc_a_H
83 #define INCLUDED_volk_32fc_x2_multiply_conjugate_32fc_a_H
84 
85 #include <inttypes.h>
86 #include <stdio.h>
87 #include <volk/volk_complex.h>
88 #include <float.h>
89 
90 #ifdef LV_HAVE_SSE3
91 #include <pmmintrin.h>
92  /*!
93  \brief Multiplies vector a by the conjugate of vector b and stores the results in the third vector
94  \param cVector The vector where the results will be stored
95  \param aVector First vector to be multiplied
96  \param bVector Second vector that is conjugated before being multiplied
97  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
98  */
99 static inline void volk_32fc_x2_multiply_conjugate_32fc_a_sse3(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
100  unsigned int number = 0;
101  const unsigned int halfPoints = num_points / 2;
102 
103  __m128 x, y, yl, yh, z, tmp1, tmp2;
104  lv_32fc_t* c = cVector;
105  const lv_32fc_t* a = aVector;
106  const lv_32fc_t* b = bVector;
107 
108  __m128 conjugator = _mm_setr_ps(0, -0.f, 0, -0.f);
109 
110  for(;number < halfPoints; number++){
111 
112  x = _mm_load_ps((float*)a); // Load the ar + ai, br + bi as ar,ai,br,bi
113  y = _mm_load_ps((float*)b); // Load the cr + ci, dr + di as cr,ci,dr,di
114 
115  y = _mm_xor_ps(y, conjugator); // conjugate y
116 
117  yl = _mm_moveldup_ps(y); // Load yl with cr,cr,dr,dr
118  yh = _mm_movehdup_ps(y); // Load yh with ci,ci,di,di
119 
120  tmp1 = _mm_mul_ps(x,yl); // tmp1 = ar*cr,ai*cr,br*dr,bi*dr
121 
122  x = _mm_shuffle_ps(x,x,0xB1); // Re-arrange x to be ai,ar,bi,br
123 
124  tmp2 = _mm_mul_ps(x,yh); // tmp2 = ai*ci,ar*ci,bi*di,br*di
125 
126  z = _mm_addsub_ps(tmp1,tmp2); // ar*cr-ai*ci, ai*cr+ar*ci, br*dr-bi*di, bi*dr+br*di
127 
128  _mm_store_ps((float*)c,z); // Store the results back into the C container
129 
130  a += 2;
131  b += 2;
132  c += 2;
133  }
134 
135  if((num_points % 2) != 0) {
136  *c = (*a) * lv_conj(*b);
137  }
138 }
139 #endif /* LV_HAVE_SSE */
140 
141 #ifdef LV_HAVE_GENERIC
142  /*!
143  \brief Multiplies vector a by the conjugate of vector b and stores the results in the third vector
144  \param cVector The vector where the results will be stored
145  \param aVector First vector to be multiplied
146  \param bVector Second vector that is conjugated before being multiplied
147  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
148  */
149 static inline void volk_32fc_x2_multiply_conjugate_32fc_a_generic(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
150  lv_32fc_t* cPtr = cVector;
151  const lv_32fc_t* aPtr = aVector;
152  const lv_32fc_t* bPtr= bVector;
153  unsigned int number = 0;
154 
155  for(number = 0; number < num_points; number++){
156  *cPtr++ = (*aPtr++) * lv_conj(*bPtr++);
157  }
158 }
159 #endif /* LV_HAVE_GENERIC */
160 
161 
162 #endif /* INCLUDED_volk_32fc_x2_multiply_conjugate_32fc_a_H */
#define lv_conj(x)
Definition: volk_complex.h:80
float complex lv_32fc_t
Definition: volk_complex.h:56