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_64f.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_64f
25  *
26  * \b Overview
27  *
28  * Deinterleaves the complex floating point vector and return the real
29  * part (inphase) of the samples that have been converted to doubles.
30  *
31  * <b>Dispatcher Prototype</b>
32  * \code
33  * void volk_32fc_deinterleave_real_64f(double* 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  * \code
45  * Generate complex numbers around the top half of the unit circle and
46  * extract all of the real parts to a double buffer.
47  * \code
48  * int N = 10;
49  * unsigned int alignment = volk_get_alignment();
50  * lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
51  * double* re = (double*)volk_malloc(sizeof(double)*N, alignment);
52  *
53  * for(unsigned int ii = 0; ii < N; ++ii){
54  * float real = 2.f * ((float)ii / (float)N) - 1.f;
55  * float imag = std::sqrt(1.f - real * real);
56  * in[ii] = lv_cmake(real, imag);
57  * }
58  *
59  * volk_32fc_deinterleave_real_64f(re, in, N);
60  *
61  * printf(" real part\n");
62  * for(unsigned int ii = 0; ii < N; ++ii){
63  * printf("out(%i) = %+.1g\n", ii, re[ii]);
64  * }
65  *
66  * volk_free(in);
67  * volk_free(re);
68  * \endcode
69  */
70 
71 #ifndef INCLUDED_volk_32fc_deinterleave_real_64f_a_H
72 #define INCLUDED_volk_32fc_deinterleave_real_64f_a_H
73 
74 #include <inttypes.h>
75 #include <stdio.h>
76 
77 #ifdef LV_HAVE_SSE2
78 #include <emmintrin.h>
79 
80 static inline void
81 volk_32fc_deinterleave_real_64f_a_sse2(double* iBuffer, const lv_32fc_t* complexVector,
82  unsigned int num_points)
83 {
84  unsigned int number = 0;
85 
86  const float* complexVectorPtr = (float*)complexVector;
87  double* iBufferPtr = iBuffer;
88 
89  const unsigned int halfPoints = num_points / 2;
90  __m128 cplxValue, fVal;
91  __m128d dVal;
92  for(;number < halfPoints; number++){
93 
94  cplxValue = _mm_load_ps(complexVectorPtr);
95  complexVectorPtr += 4;
96 
97  // Arrange in i1i2i1i2 format
98  fVal = _mm_shuffle_ps(cplxValue, cplxValue, _MM_SHUFFLE(2,0,2,0));
99  dVal = _mm_cvtps_pd(fVal);
100  _mm_store_pd(iBufferPtr, dVal);
101 
102  iBufferPtr += 2;
103  }
104 
105  number = halfPoints * 2;
106  for(; number < num_points; number++){
107  *iBufferPtr++ = (double)*complexVectorPtr++;
108  complexVectorPtr++;
109  }
110 }
111 #endif /* LV_HAVE_SSE */
112 
113 
114 #ifdef LV_HAVE_GENERIC
115 
116 static inline void
117 volk_32fc_deinterleave_real_64f_generic(double* iBuffer, const lv_32fc_t* complexVector,
118  unsigned int num_points)
119 {
120  unsigned int number = 0;
121  const float* complexVectorPtr = (float*)complexVector;
122  double* iBufferPtr = iBuffer;
123  for(number = 0; number < num_points; number++){
124  *iBufferPtr++ = (double)*complexVectorPtr++;
125  complexVectorPtr++;
126  }
127 }
128 #endif /* LV_HAVE_GENERIC */
129 
130 #endif /* INCLUDED_volk_32fc_deinterleave_real_64f_a_H */
float complex lv_32fc_t
Definition: volk_complex.h:56