From 45221bd3e8ad6be56cb0ba471aa6a1d06e9efc0b Mon Sep 17 00:00:00 2001 From: trondeau Date: Sun, 17 Dec 2006 01:40:33 +0000 Subject: changed complex_to_arg to use fast atan and updated QA 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 | 4 +++- .../src/python/gnuradio/gr/qa_complex_to_xxx.py | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'gnuradio-core') diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc index 2bfc24166..2bd4acac7 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc @@ -26,6 +26,7 @@ #include #include +#include // ---------------------------------------------------------------- @@ -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; } diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py b/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py index 04133d309..1cfc2642a 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py @@ -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) -- cgit