From b2a373eb642077fbf5f1bdbe74d1e82cc534f5f2 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sat, 30 Sep 2017 22:48:41 -0400 Subject: Replace fp_sqrt function with one that only uses shift, or and sub. Simply extends the current isqrt() to be able to do fractional bits and improves the initial estimate using clz(). iqrt() itself is no more and is equivalent to fp_sqrt(x, 0). The original also had a small bug where the guess comparision should have been >=, not >. Uses no large integer math or division and is very accurate (simply returns a truncated fraction). Change-Id: I2ae26e6505df1770dc01e56220f7385369f90ae9 --- apps/plugins/fft/fft.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c index 40c251de15..3e88722b23 100644 --- a/apps/plugins/fft/fft.c +++ b/apps/plugins/fft/fft.c @@ -624,16 +624,16 @@ static unsigned calc_magnitudes(enum fft_amp_scale scale) } else { - d = isqrt(d); /* linear scaling, nothing - bad should happen */ + d = fp_sqrt(d, 0); /* linear scaling, nothing + bad should happen */ d = fp16_log(d << 16); /* the log function expects s15.16 values */ } } else { - d = isqrt(d); /* linear scaling, nothing - bad should happen */ + d = fp_sqrt(d, 0); /* linear scaling, nothing + bad should happen */ } } -- cgit v1.2.3