commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 06/13: runtime: math: in fast_atan2f, moved


From: git
Subject: [Commit-gnuradio] [gnuradio] 06/13: runtime: math: in fast_atan2f, moved nested if that checks for divide by zero out into its own check.
Date: Thu, 4 Dec 2014 16:21:50 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit 114494fabbeb552ebe7b40fb6344418ffac8e736
Author: Tom Rondeau <address@hidden>
Date:   Tue Nov 25 09:03:50 2014 -0500

    runtime: math: in fast_atan2f, moved nested if that checks for divide by 
zero out into its own check.
    
    This change mostly affects ARM processors. They seem to not do well with 
nest branches whereas x86 do fine. Breaking out this nested if makes no 
computational difference on x86 but makes a ~5-6% improvement for the ARMv7 
tests.
    
    Also updates the docs to reflect the new mean error from the function.
---
 gnuradio-runtime/lib/math/fast_atan2f.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gnuradio-runtime/lib/math/fast_atan2f.cc 
b/gnuradio-runtime/lib/math/fast_atan2f.cc
index a5ff1cd..f968310 100644
--- a/gnuradio-runtime/lib/math/fast_atan2f.cc
+++ b/gnuradio-runtime/lib/math/fast_atan2f.cc
@@ -118,7 +118,7 @@ namespace gr {
    determine the final angle value in the range of -180 to 180
    degrees. Note that this function uses the small angle approximation
    for values close to zero. This routine calculates the arc tangent
-   with an average error of +/- 0.045 degrees.
+   with an average error of +/- 3.56e-5 degrees (6.21e-7 radians).
   
*****************************************************************************/
 
   float
@@ -131,11 +131,14 @@ namespace gr {
     /* normalize to +/- 45 degree range */
     y_abs = fabsf(y);
     x_abs = fabsf(x);
+    /* don't divide by zero! */
+    if(!((y_abs > 0.0f) || (x_abs > 0.0f)))
+      return 0.0;
 
-       if (y_abs < x_abs)
-      if (x_abs > 0.0) z = y_abs / x_abs; else return 0.0;
+    if(y_abs < x_abs)
+      z = y_abs / x_abs;
     else
-      if (y_abs > 0.0) z = x_abs / y_abs; else return 0.0;
+      z = x_abs / y_abs;
 
     /* when ratio approaches the table resolution, the angle is */
     /* best approximated with the argument itself... */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]