1 #ifndef INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_a_H
2 #define INCLUDED_volk_32f_s32f_calc_spectral_noise_floor_32f_a_H
20 static inline void volk_32f_s32f_calc_spectral_noise_floor_32f_a_sse(
float* noiseFloorAmplitude,
const float* realDataPoints,
const float spectralExclusionValue,
const unsigned int num_points){
21 unsigned int number = 0;
22 const unsigned int quarterPoints = num_points / 4;
24 const float* dataPointsPtr = realDataPoints;
28 __m128 avgPointsVal = _mm_setzero_ps();
30 for(; number < quarterPoints; number++){
32 dataPointsVal = _mm_load_ps(dataPointsPtr);
36 avgPointsVal = _mm_add_ps(avgPointsVal, dataPointsVal);
39 _mm_store_ps(avgPointsVector, avgPointsVal);
42 sumMean += avgPointsVector[0];
43 sumMean += avgPointsVector[1];
44 sumMean += avgPointsVector[2];
45 sumMean += avgPointsVector[3];
47 number = quarterPoints * 4;
48 for(;number < num_points; number++){
49 sumMean += realDataPoints[number];
55 const float meanAmplitude = (sumMean / ((float)num_points)) + spectralExclusionValue;
57 dataPointsPtr = realDataPoints;
58 __m128 vMeanAmplitudeVector = _mm_set_ps1(meanAmplitude);
59 __m128 vOnesVector = _mm_set_ps1(1.0);
60 __m128 vValidBinCount = _mm_setzero_ps();
61 avgPointsVal = _mm_setzero_ps();
65 for(; number < quarterPoints; number++){
67 dataPointsVal = _mm_load_ps(dataPointsPtr);
72 compareMask = _mm_cmple_ps(dataPointsVal, vMeanAmplitudeVector);
75 avgPointsVal = _mm_add_ps(avgPointsVal, _mm_and_ps(compareMask, dataPointsVal));
78 vValidBinCount = _mm_add_ps(vValidBinCount, _mm_and_ps(compareMask, vOnesVector));
82 _mm_store_ps(avgPointsVector, avgPointsVal);
85 sumMean += avgPointsVector[0];
86 sumMean += avgPointsVector[1];
87 sumMean += avgPointsVector[2];
88 sumMean += avgPointsVector[3];
92 _mm_store_ps(validBinCountVector, vValidBinCount);
94 float validBinCount = 0;
95 validBinCount += validBinCountVector[0];
96 validBinCount += validBinCountVector[1];
97 validBinCount += validBinCountVector[2];
98 validBinCount += validBinCountVector[3];
100 number = quarterPoints * 4;
101 for(;number < num_points; number++){
102 if(realDataPoints[number] <= meanAmplitude){
103 sumMean += realDataPoints[number];
104 validBinCount += 1.0;
108 float localNoiseFloorAmplitude = 0;
109 if(validBinCount > 0.0){
110 localNoiseFloorAmplitude = sumMean / validBinCount;
113 localNoiseFloorAmplitude = meanAmplitude;
116 *noiseFloorAmplitude = localNoiseFloorAmplitude;
120 #ifdef LV_HAVE_GENERIC
131 static inline void volk_32f_s32f_calc_spectral_noise_floor_32f_generic(
float* noiseFloorAmplitude,
const float* realDataPoints,
const float spectralExclusionValue,
const unsigned int num_points){
135 for(number = 0; number < num_points; number++){
137 sumMean += realDataPoints[number];
143 const float meanAmplitude = (sumMean / num_points) + spectralExclusionValue;
147 unsigned int newNumDataPoints = num_points;
148 for(number = 0; number < num_points; number++){
149 if (realDataPoints[number] <= meanAmplitude)
150 sumMean += realDataPoints[number];
155 float localNoiseFloorAmplitude = 0.0;
156 if (newNumDataPoints == 0)
157 localNoiseFloorAmplitude = meanAmplitude;
159 localNoiseFloorAmplitude = sumMean / ((float)newNumDataPoints);
161 *noiseFloorAmplitude = localNoiseFloorAmplitude;
#define __VOLK_ATTR_ALIGNED(x)
Definition: volk_common.h:27