changed complex_to_arg to use fast atan and updated QA
authortrondeau <trondeau@221aa14e-8319-0410-a670-987f0aec2ac5>
Sun, 17 Dec 2006 01:40:33 +0000 (01:40 +0000)
committertrondeau <trondeau@221aa14e-8319-0410-a670-987f0aec2ac5>
Sun, 17 Dec 2006 01:40:33 +0000 (01:40 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4109 221aa14e-8319-0410-a670-987f0aec2ac5

gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py

index 2bfc241660a451f45f5359d035e27c4418cd4cc6..2bd4acac74165a1178838bb5e0371b9d0f439b2c 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <gr_complex_to_xxx.h>
 #include <gr_io_signature.h>
+#include <gr_math.h>
 
 // ----------------------------------------------------------------
 
@@ -226,7 +227,8 @@ gr_complex_to_arg::work (int noutput_items,
   int noi = noutput_items * d_vlen;
 
   for (int i = 0; i < noi; i++){
-    out[i] = std::arg (in[i]);
+    //    out[i] = std::arg (in[i]);
+    out[i] = gr_fast_atan2f(in[i]);
   }
   return noutput_items;
 }
index 04133d3093276e0341bc7b6e80ed84303617dba9..1cfc2642abbd7573b487474f4f4e5dd515673f90 100755 (executable)
@@ -110,9 +110,22 @@ class test_complex_ops (gr_unittest.TestCase):
 
     def test_complex_to_arg (self):
         pi = math.pi
-        expected_result = (0, pi/6, pi/4, pi/2, 3*pi/4, 7*pi/8,
-                           -pi/6, -pi/4, -pi/2, -3*pi/4, -7*pi/8)
-        src_data = tuple ([math.cos (x) + math.sin (x) * 1j for x in expected_result])
+        input_data = (0, pi/6, pi/4, pi/2, 3*pi/4, 7*pi/8,
+                      -pi/6, -pi/4, -pi/2, -3*pi/4, -7*pi/8)
+
+        expected_result = (0.0,                  # 0
+                           0.52382522821426392,  # pi/6
+                           0.78539806604385376,  # pi/4
+                           1.5707963705062866,   # pi/2
+                           2.3561947345733643,   # 3pi/4
+                           2.7491819858551025,   # 7pi/8
+                           -0.52382522821426392, # -pi/6
+                           -0.78539806604385376, # -pi/4
+                           -1.5707963705062866,  # -pi/2
+                           -2.3561947345733643,  # -3pi/4
+                           -2.7491819858551025)  # -7pi/8
+
+        src_data = tuple ([math.cos (x) + math.sin (x) * 1j for x in input_data])
         src = gr.vector_source_c (src_data)
         op = gr.complex_to_arg ()
         dst = gr.vector_sink_f ()
@@ -120,6 +133,7 @@ class test_complex_ops (gr_unittest.TestCase):
         self.fg.connect (op, dst)
         self.fg.run ()
         actual_result = dst.data ()
+
         self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 5)