GNU Radio Manual and C++ API Reference  3.7.7
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
volk_32fc_deinterleave_real_32f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012, 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 /*!
24  * \page volk_32fc_deinterleave_real_32f
25  *
26  * \b Overview
27  *
28  * Deinterleaves the complex floating point vector and return the real
29  * part (inphase) of the samples.
30  *
31  * <b>Dispatcher Prototype</b>
32  * \code
33  * void volk_32fc_deinterleave_real_32f(float* iBuffer, const lv_32fc_t* complexVector, unsigned int num_points)
34  * \endcode
35  *
36  * \b Inputs
37  * \li complexVector: The complex input vector.
38  * \li num_points: The number of complex data values to be deinterleaved.
39  *
40  * \b Outputs
41  * \li iBuffer: The I buffer output data.
42  *
43  * \b Example
44  * Generate complex numbers around the top half of the unit circle and
45  * extract all of the real parts to a float buffer.
46  * \code
47  * int N = 10;
48  * unsigned int alignment = volk_get_alignment();
49  * lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
50  * float* re = (float*)volk_malloc(sizeof(float)*N, alignment);
51  *
52  * for(unsigned int ii = 0; ii < N; ++ii){
53  * float real = 2.f * ((float)ii / (float)N) - 1.f;
54  * float imag = std::sqrt(1.f - real * real);
55  * in[ii] = lv_cmake(real, imag);
56  * }
57  *
58  * volk_32fc_deinterleave_real_32f(re, in, N);
59  *
60  * printf(" real part\n");
61  * for(unsigned int ii = 0; ii < N; ++ii){
62  * printf("out(%i) = %+.1f\n", ii, re[ii]);
63  * }
64  *
65  * volk_free(in);
66  * volk_free(re);
67  * \endcode
68  */
69 
70 #ifndef INCLUDED_volk_32fc_deinterleave_real_32f_a_H
71 #define INCLUDED_volk_32fc_deinterleave_real_32f_a_H
72 
73 #include <inttypes.h>
74 #include <stdio.h>
75 
76 #ifdef LV_HAVE_SSE
77 #include <xmmintrin.h>
78 
79 static inline void
80 volk_32fc_deinterleave_real_32f_a_sse(float* iBuffer, const lv_32fc_t* complexVector,
81  unsigned int num_points)
82 {
83  unsigned int number = 0;
84  const unsigned int quarterPoints = num_points / 4;
85 
86  const float* complexVectorPtr = (const float*)complexVector;
87  float* iBufferPtr = iBuffer;
88 
89  __m128 cplxValue1, cplxValue2, iValue;
90  for(;number < quarterPoints; number++){
91 
92  cplxValue1 = _mm_load_ps(complexVectorPtr);
93  complexVectorPtr += 4;
94 
95  cplxValue2 = _mm_load_ps(complexVectorPtr);
96  complexVectorPtr += 4;
97 
98  // Arrange in i1i2i3i4 format
99  iValue = _mm_shuffle_ps(cplxValue1, cplxValue2, _MM_SHUFFLE(2,0,2,0));
100 
101  _mm_store_ps(iBufferPtr, iValue);
102 
103  iBufferPtr += 4;
104  }
105 
106  number = quarterPoints * 4;
107  for(; number < num_points; number++){
108  *iBufferPtr++ = *complexVectorPtr++;
109  complexVectorPtr++;
110  }
111 }
112 #endif /* LV_HAVE_SSE */
113 
114 
115 #ifdef LV_HAVE_GENERIC
116 
117 static inline void
118 volk_32fc_deinterleave_real_32f_generic(float* iBuffer, const lv_32fc_t* complexVector,
119  unsigned int num_points)
120 {
121  unsigned int number = 0;
122  const float* complexVectorPtr = (float*)complexVector;
123  float* iBufferPtr = iBuffer;
124  for(number = 0; number < num_points; number++){
125  *iBufferPtr++ = *complexVectorPtr++;
126  complexVectorPtr++;
127  }
128 }
129 #endif /* LV_HAVE_GENERIC */
130 
131 
132 #ifdef LV_HAVE_NEON
133 #include <arm_neon.h>
134 
135 static inline void
136 volk_32fc_deinterleave_real_32f_neon(float* iBuffer, const lv_32fc_t* complexVector,
137  unsigned int num_points)
138 {
139  unsigned int number = 0;
140  unsigned int quarter_points = num_points / 4;
141  const float* complexVectorPtr = (float*)complexVector;
142  float* iBufferPtr = iBuffer;
143  float32x4x2_t complexInput;
144 
145  for(number = 0; number < quarter_points; number++){
146  complexInput = vld2q_f32(complexVectorPtr);
147  vst1q_f32( iBufferPtr, complexInput.val[0] );
148  complexVectorPtr += 8;
149  iBufferPtr += 4;
150  }
151 
152  for(number = quarter_points*4; number < num_points; number++){
153  *iBufferPtr++ = *complexVectorPtr++;
154  complexVectorPtr++;
155  }
156 }
157 #endif /* LV_HAVE_NEON */
158 
159 #endif /* INCLUDED_volk_32fc_deinterleave_real_32f_a_H */
float complex lv_32fc_t
Definition: volk_complex.h:56