Fixes #107: srslte_simd_f_sqrt NaN solved if input is 0

This commit is contained in:
Xavier Arteaga 2017-11-22 12:23:46 +01:00
parent 0093497752
commit 91e706d4d1
2 changed files with 7 additions and 1 deletions

View file

@ -449,7 +449,12 @@ static inline simd_f_t srslte_simd_f_sqrt(simd_f_t a) {
#ifdef HAVE_NEON
float32x4_t sqrt_reciprocal = vrsqrteq_f32(a);
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 /* LV_HAVE_SSE */
#endif /* LV_HAVE_AVX2 */

View file

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