GNU Radio 3.5.3.2 C++ API
volk_32fc_x2_multiply_32fc_a.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_32fc_x2_multiply_32fc_a_H
2 #define INCLUDED_volk_32fc_x2_multiply_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 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_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  for(;number < halfPoints; number++){
27 
28  x = _mm_load_ps((float*)a); // Load the ar + ai, br + bi as ar,ai,br,bi
29  y = _mm_load_ps((float*)b); // Load the cr + ci, dr + di as cr,ci,dr,di
30 
31  yl = _mm_moveldup_ps(y); // Load yl with cr,cr,dr,dr
32  yh = _mm_movehdup_ps(y); // Load yh with ci,ci,di,di
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_store_ps((float*)c,z); // Store the results back into the C container
43 
44  a += 2;
45  b += 2;
46  c += 2;
47  }
48 
49  if((num_points % 2) != 0) {
50  *c = (*a) * (*b);
51  }
52 }
53 #endif /* LV_HAVE_SSE */
54 
55 #ifdef LV_HAVE_GENERIC
56  /*!
57  \brief Multiplies the two input complex vectors and stores their results in the third vector
58  \param cVector The vector where the results will be stored
59  \param aVector One of the vectors to be multiplied
60  \param bVector One of the vectors to be multiplied
61  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
62  */
63 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){
64  lv_32fc_t* cPtr = cVector;
65  const lv_32fc_t* aPtr = aVector;
66  const lv_32fc_t* bPtr= bVector;
67  unsigned int number = 0;
68 
69  for(number = 0; number < num_points; number++){
70  *cPtr++ = (*aPtr++) * (*bPtr++);
71  }
72 }
73 #endif /* LV_HAVE_GENERIC */
74 
75 #ifdef LV_HAVE_ORC
76  /*!
77  \brief Multiplies the two input complex vectors and stores their results in the third vector
78  \param cVector The vector where the results will be stored
79  \param aVector One of the vectors to be multiplied
80  \param bVector One of the vectors to be multiplied
81  \param num_points The number of complex values in aVector and bVector to be multiplied together and stored into cVector
82  */
83 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);
84 static inline void volk_32fc_x2_multiply_32fc_a_orc(lv_32fc_t* cVector, const lv_32fc_t* aVector, const lv_32fc_t* bVector, unsigned int num_points){
85  volk_32fc_x2_multiply_32fc_a_orc_impl(cVector, aVector, bVector, num_points);
86 }
87 #endif /* LV_HAVE_ORC */
88 
89 
90 
91 
92 
93 #endif /* INCLUDED_volk_32fc_x2_multiply_32fc_a_H */