AM中波放送用SDR.CICフィルタのみを使用.CQ出版社「トランジスタ技術」誌,2021年4月号に掲載

Dependencies:   mbed

Revision:
2:4bec6b2be809
Parent:
1:30d9fb51dec1
--- a/SDR_Library/FastATan.hpp	Mon Sep 23 07:32:10 2019 +0000
+++ b/SDR_Library/FastATan.hpp	Sat Aug 29 11:19:03 2020 +0000
@@ -3,7 +3,7 @@
 //      係数はミニマックス近似で求めたもの
 //      ただし,誤差は絶対誤差で評価した
 //
-//  2019/09/18, Copyright (c) 2019 MIKAMI, Naoki
+//  2020/08/12, Copyright (c) 2020 MIKAMI, Naoki
 //--------------------------------------------------------------
 
 #include "mbed.h"
@@ -24,40 +24,27 @@
         static const float PI_2  = PI/2.0f;        // π/2
 
         if ( (x == 0.0f) && (y == 0.0f) ) return 0.0f;
-        if (y == 0.0f)
-        {
-            if (x > 0.0f) return 0.0f;      // 0
-            else          return PI;        // π
-        }
+        if (y == 0.0f) return (x > 0.0f) ? 0.0f : PI;
+
         float abs_x = fabsf(x);
         float abs_y = fabsf(y);
 
         if (abs_x == abs_y)
         {
-            if (x > 0.0f)
-            {
-                if (y > 0.0f) return PI_4;  // π/4
-                else          return -PI_4; // -π/4
-            }
-            else
-            {
-                if (y > 0.0f) return PI3_4;  // 3π/4
-                else          return -PI3_4; // -3π/4
-            }
+            if (x > 0.0f) return (y > 0.0f) ?  PI_4 : -PI_4;
+            else          return (y > 0.0f) ? PI3_4 : -PI3_4;
         }
 
         if (abs_x > abs_y)  // |θ|< π/4,3π/4<|θ|<π
         {
             float u = ATanPoly(y/x);
             if (x > 0.0f) return u;
-            if (y > 0.0f) return u + PI;
-            else          return u - PI;
+            else          return (y > 0.0f) ? u + PI : u - PI;
         }
         else                // π/4 <|θ|<3π/4
         {
             float u = ATanPoly(x/y);
-            if (y > 0.0f) return -u + PI_2;
-            else          return -u - PI_2;
+            return (y > 0.0f) ? -u + PI_2 : -u - PI_2;
         }
     }
 
@@ -74,4 +61,4 @@
         return atanx;
     }
 }
-#endif  // FAST_ARCTAN_LOW_PRECISION_HPP
+#endif  // FAST_ARCTAN_LOW_PRECISION_HPP
\ No newline at end of file