71 unsigned int num_points)
73 unsigned int number = 0;
74 const unsigned int eighthPoints = num_points / 8;
76 const float* complexVectorPtr = (
float*)complexVector;
77 float* magnitudeVectorPtr = magnitudeVector;
79 __m256 cplxValue1, cplxValue2, result;
81 for (; number < eighthPoints; number++) {
82 cplxValue1 = _mm256_loadu_ps(complexVectorPtr);
83 cplxValue2 = _mm256_loadu_ps(complexVectorPtr + 8);
85 _mm256_storeu_ps(magnitudeVectorPtr, result);
87 complexVectorPtr += 16;
88 magnitudeVectorPtr += 8;
91 number = eighthPoints * 8;
92 for (; number < num_points; number++) {
93 float val1Real = *complexVectorPtr++;
94 float val1Imag = *complexVectorPtr++;
95 *magnitudeVectorPtr++ = sqrtf((val1Real * val1Real) + (val1Imag * val1Imag));
106 unsigned int num_points)
108 unsigned int number = 0;
109 const unsigned int quarterPoints = num_points / 4;
111 const float* complexVectorPtr = (
float*)complexVector;
112 float* magnitudeVectorPtr = magnitudeVector;
114 __m128 cplxValue1, cplxValue2, result;
115 for (; number < quarterPoints; number++) {
116 cplxValue1 = _mm_loadu_ps(complexVectorPtr);
117 complexVectorPtr += 4;
119 cplxValue2 = _mm_loadu_ps(complexVectorPtr);
120 complexVectorPtr += 4;
124 _mm_storeu_ps(magnitudeVectorPtr, result);
125 magnitudeVectorPtr += 4;
128 number = quarterPoints * 4;
129 for (; number < num_points; number++) {
130 float val1Real = *complexVectorPtr++;
131 float val1Imag = *complexVectorPtr++;
132 *magnitudeVectorPtr++ = sqrtf((val1Real * val1Real) + (val1Imag * val1Imag));
144 unsigned int num_points)
146 unsigned int number = 0;
147 const unsigned int quarterPoints = num_points / 4;
149 const float* complexVectorPtr = (
float*)complexVector;
150 float* magnitudeVectorPtr = magnitudeVector;
152 __m128 cplxValue1, cplxValue2, result;
154 for (; number < quarterPoints; number++) {
155 cplxValue1 = _mm_loadu_ps(complexVectorPtr);
156 complexVectorPtr += 4;
158 cplxValue2 = _mm_loadu_ps(complexVectorPtr);
159 complexVectorPtr += 4;
162 _mm_storeu_ps(magnitudeVectorPtr, result);
163 magnitudeVectorPtr += 4;
166 number = quarterPoints * 4;
167 for (; number < num_points; number++) {
168 float val1Real = *complexVectorPtr++;
169 float val1Imag = *complexVectorPtr++;
170 *magnitudeVectorPtr++ = sqrtf((val1Real * val1Real) + (val1Imag * val1Imag));
208 unsigned int num_points)
210 unsigned int number = 0;
211 const unsigned int eighthPoints = num_points / 8;
213 const float* complexVectorPtr = (
float*)complexVector;
214 float* magnitudeVectorPtr = magnitudeVector;
216 __m256 cplxValue1, cplxValue2, result;
217 for (; number < eighthPoints; number++) {
218 cplxValue1 = _mm256_load_ps(complexVectorPtr);
219 complexVectorPtr += 8;
221 cplxValue2 = _mm256_load_ps(complexVectorPtr);
222 complexVectorPtr += 8;
225 _mm256_store_ps(magnitudeVectorPtr, result);
226 magnitudeVectorPtr += 8;
229 number = eighthPoints * 8;
230 for (; number < num_points; number++) {
231 float val1Real = *complexVectorPtr++;
232 float val1Imag = *complexVectorPtr++;
233 *magnitudeVectorPtr++ = sqrtf((val1Real * val1Real) + (val1Imag * val1Imag));
244 unsigned int num_points)
246 unsigned int number = 0;
247 const unsigned int quarterPoints = num_points / 4;
249 const float* complexVectorPtr = (
float*)complexVector;
250 float* magnitudeVectorPtr = magnitudeVector;
252 __m128 cplxValue1, cplxValue2, result;
253 for (; number < quarterPoints; number++) {
254 cplxValue1 = _mm_load_ps(complexVectorPtr);
255 complexVectorPtr += 4;
257 cplxValue2 = _mm_load_ps(complexVectorPtr);
258 complexVectorPtr += 4;
261 _mm_store_ps(magnitudeVectorPtr, result);
262 magnitudeVectorPtr += 4;
265 number = quarterPoints * 4;
266 for (; number < num_points; number++) {
267 float val1Real = *complexVectorPtr++;
268 float val1Imag = *complexVectorPtr++;
269 *magnitudeVectorPtr++ = sqrtf((val1Real * val1Real) + (val1Imag * val1Imag));
280 unsigned int num_points)
282 unsigned int number = 0;
283 const unsigned int quarterPoints = num_points / 4;
285 const float* complexVectorPtr = (
float*)complexVector;
286 float* magnitudeVectorPtr = magnitudeVector;
288 __m128 cplxValue1, cplxValue2, result;
289 for (; number < quarterPoints; number++) {
290 cplxValue1 = _mm_load_ps(complexVectorPtr);
291 complexVectorPtr += 4;
293 cplxValue2 = _mm_load_ps(complexVectorPtr);
294 complexVectorPtr += 4;
297 _mm_store_ps(magnitudeVectorPtr, result);
298 magnitudeVectorPtr += 4;
301 number = quarterPoints * 4;
302 for (; number < num_points; number++) {
303 float val1Real = *complexVectorPtr++;
304 float val1Imag = *complexVectorPtr++;
305 *magnitudeVectorPtr++ = sqrtf((val1Real * val1Real) + (val1Imag * val1Imag));
316 unsigned int num_points)
319 unsigned int quarter_points = num_points / 4;
320 const float* complexVectorPtr = (
float*)complexVector;
321 float* magnitudeVectorPtr = magnitudeVector;
323 float32x4x2_t complex_vec;
324 float32x4_t magnitude_vec;
325 for (number = 0; number < quarter_points; number++) {
326 complex_vec = vld2q_f32(complexVectorPtr);
327 complex_vec.val[0] = vmulq_f32(complex_vec.val[0], complex_vec.val[0]);
329 vmlaq_f32(complex_vec.val[0], complex_vec.val[1], complex_vec.val[1]);
330 magnitude_vec = vrsqrteq_f32(magnitude_vec);
331 magnitude_vec = vrecpeq_f32(magnitude_vec);
332 vst1q_f32(magnitudeVectorPtr, magnitude_vec);
334 complexVectorPtr += 8;
335 magnitudeVectorPtr += 4;
338 for (number = quarter_points * 4; number < num_points; number++) {
339 const float real = *complexVectorPtr++;
340 const float imag = *complexVectorPtr++;
341 *magnitudeVectorPtr++ = sqrtf((real * real) + (imag * imag));
365 float* magnitudeVector,
const lv_32fc_t* complexVector,
unsigned int num_points)
368 unsigned int quarter_points = num_points / 4;
369 const float* complexVectorPtr = (
float*)complexVector;
370 float* magnitudeVectorPtr = magnitudeVector;
372 const float threshold = 0.4142135;
374 float32x4_t a_vec, b_vec, a_high, a_low, b_high, b_low;
375 a_high = vdupq_n_f32(0.84);
376 b_high = vdupq_n_f32(0.561);
377 a_low = vdupq_n_f32(0.99);
378 b_low = vdupq_n_f32(0.197);
380 uint32x4_t comp0, comp1;
382 float32x4x2_t complex_vec;
383 float32x4_t min_vec, max_vec, magnitude_vec;
384 float32x4_t real_abs, imag_abs;
385 for (number = 0; number < quarter_points; number++) {
386 complex_vec = vld2q_f32(complexVectorPtr);
388 real_abs = vabsq_f32(complex_vec.val[0]);
389 imag_abs = vabsq_f32(complex_vec.val[1]);
391 min_vec = vminq_f32(real_abs, imag_abs);
392 max_vec = vmaxq_f32(real_abs, imag_abs);
395 comp0 = vcgtq_f32(min_vec, vmulq_n_f32(max_vec, threshold));
396 comp1 = vcleq_f32(min_vec, vmulq_n_f32(max_vec, threshold));
399 a_vec = (float32x4_t)vaddq_s32(vandq_s32((int32x4_t)comp0, (int32x4_t)a_high),
400 vandq_s32((int32x4_t)comp1, (int32x4_t)a_low));
401 b_vec = (float32x4_t)vaddq_s32(vandq_s32((int32x4_t)comp0, (int32x4_t)b_high),
402 vandq_s32((int32x4_t)comp1, (int32x4_t)b_low));
405 min_vec = vmulq_f32(min_vec, b_vec);
406 max_vec = vmulq_f32(max_vec, a_vec);
408 magnitude_vec = vaddq_f32(min_vec, max_vec);
409 vst1q_f32(magnitudeVectorPtr, magnitude_vec);
411 complexVectorPtr += 8;
412 magnitudeVectorPtr += 4;
415 for (number = quarter_points * 4; number < num_points; number++) {
416 const float real = *complexVectorPtr++;
417 const float imag = *complexVectorPtr++;
418 *magnitudeVectorPtr++ = sqrtf((real * real) + (imag * imag));
433 vuint64m8_t vc = __riscv_vle64_v_u64m8((
const uint64_t*)complexVector, vl);
436 vfloat32m4_t v = __riscv_vfmacc(__riscv_vfmul(vi, vi, vl), vr, vr, vl);
437 __riscv_vse32(magnitudeVector, __riscv_vfsqrt(v, vl), vl);
455 vfloat32m4_t v = __riscv_vfmacc(__riscv_vfmul(vi, vi, vl), vr, vr, vl);
456 __riscv_vse32(magnitudeVector, __riscv_vfsqrt(v, vl), vl);