GNU Radio 3.6.5.1 C++ API
volk_32fc_x2_multiply_conjugate_32fc_a.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32fc_x2_multiply_conjugate_32fc_a_H
2 #define INCLUDED_volk_32fc_x2_multiply_conjugate_32fc_a_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_a_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_load_ps((float*)a); // Load the ar + ai, br + bi as ar,ai,br,bi
32  y = _mm_load_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_store_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_a_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_a_H */