GNU Radio Manual and C++ API Reference  3.7.6.1
The Free & Open Software Radio Ecosystem
volk_32f_s32f_normalize.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 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 #ifndef INCLUDED_volk_32f_s32f_normalize_a_H
24 #define INCLUDED_volk_32f_s32f_normalize_a_H
25 
26 #include <inttypes.h>
27 #include <stdio.h>
28 
29 #ifdef LV_HAVE_SSE
30 #include <xmmintrin.h>
31 /*!
32  \brief Normalizes all points in the buffer by the scalar value ( divides each data point by the scalar value )
33  \param vecBuffer The buffer of values to be vectorized
34  \param num_points The number of values in vecBuffer
35  \param scalar The scale value to be applied to each buffer value
36 */
37 static inline void volk_32f_s32f_normalize_a_sse(float* vecBuffer, const float scalar, unsigned int num_points){
38  unsigned int number = 0;
39  float* inputPtr = vecBuffer;
40 
41  const float invScalar = 1.0 / scalar;
42  __m128 vecScalar = _mm_set_ps1(invScalar);
43 
44  __m128 input1;
45 
46  const uint64_t quarterPoints = num_points / 4;
47  for(;number < quarterPoints; number++){
48 
49  input1 = _mm_load_ps(inputPtr);
50 
51  input1 = _mm_mul_ps(input1, vecScalar);
52 
53  _mm_store_ps(inputPtr, input1);
54 
55  inputPtr += 4;
56  }
57 
58  number = quarterPoints*4;
59  for(; number < num_points; number++){
60  *inputPtr *= invScalar;
61  inputPtr++;
62  }
63 }
64 #endif /* LV_HAVE_SSE */
65 
66 #ifdef LV_HAVE_GENERIC
67 /*!
68  \brief Normalizes the two input vectors and store their results in the third vector
69  \param cVector The vector where the results will be stored
70  \param aVector One of the vectors to be normalizeed
71  \param bVector One of the vectors to be normalizeed
72  \param num_points The number of values in aVector and bVector to be normalizeed together and stored into cVector
73 */
74 static inline void volk_32f_s32f_normalize_generic(float* vecBuffer, const float scalar, unsigned int num_points){
75  unsigned int number = 0;
76  float* inputPtr = vecBuffer;
77  const float invScalar = 1.0 / scalar;
78  for(number = 0; number < num_points; number++){
79  *inputPtr *= invScalar;
80  inputPtr++;
81  }
82 }
83 #endif /* LV_HAVE_GENERIC */
84 
85 #ifdef LV_HAVE_ORC
86 /*!
87  \brief Normalizes the two input vectors and store their results in the third vector
88  \param cVector The vector where the results will be stored
89  \param aVector One of the vectors to be normalizeed
90  \param bVector One of the vectors to be normalizeed
91  \param num_points The number of values in aVector and bVector to be normalizeed together and stored into cVector
92 */
93 extern void volk_32f_s32f_normalize_a_orc_impl(float* dst, float* src, const float scalar, unsigned int num_points);
94 static inline void volk_32f_s32f_normalize_u_orc(float* vecBuffer, const float scalar, unsigned int num_points){
95  float invscalar = 1.0 / scalar;
96  volk_32f_s32f_normalize_a_orc_impl(vecBuffer, vecBuffer, invscalar, num_points);
97 }
98 #endif /* LV_HAVE_GENERIC */
99 
100 
101 
102 
103 #endif /* INCLUDED_volk_32f_s32f_normalize_a_H */
unsigned __int64 uint64_t
Definition: stdint.h:90