Fixes #107: srslte_simd_f_sqrt NaN solved if input is 0

master
Xavier Arteaga 7 years ago
parent 0093497752
commit 91e706d4d1

@ -449,7 +449,12 @@ static inline simd_f_t srslte_simd_f_sqrt(simd_f_t a) {
#ifdef HAVE_NEON #ifdef HAVE_NEON
float32x4_t sqrt_reciprocal = vrsqrteq_f32(a); float32x4_t sqrt_reciprocal = vrsqrteq_f32(a);
sqrt_reciprocal = vmulq_f32(vrsqrtsq_f32(vmulq_f32(a,sqrt_reciprocal), sqrt_reciprocal),sqrt_reciprocal); sqrt_reciprocal = vmulq_f32(vrsqrtsq_f32(vmulq_f32(a,sqrt_reciprocal), sqrt_reciprocal),sqrt_reciprocal);
return vmulq_f32(a,sqrt_reciprocal); float32x4_t result = vmulq_f32(a,sqrt_reciprocal);
/* Detect zeros in NEON 1/sqrtf for preventing NaN */
float32x4_t zeros = vmovq_n_f32(0); /* Zero vector */
uint32x4_t mask = vceqq_f32(a, zeros); /* Zero vector mask */
return vbslq_f32(mask, zeros, result); /* Force zero results and return */
#endif /* HAVE_NEON */ #endif /* HAVE_NEON */
#endif /* LV_HAVE_SSE */ #endif /* LV_HAVE_SSE */
#endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX2 */

@ -502,6 +502,7 @@ TEST(srslte_vec_abs_cf,
for (int i = 0; i < block_size; i++) { for (int i = 0; i < block_size; i++) {
x[i] = RANDOM_CF(); x[i] = RANDOM_CF();
} }
x[0] = 0.0f;
TEST_CALL(srslte_vec_abs_cf(x, z, block_size)) TEST_CALL(srslte_vec_abs_cf(x, z, block_size))

Loading…
Cancel
Save