diff options
author | trondeau | 2006-12-17 01:40:33 +0000 |
---|---|---|
committer | trondeau | 2006-12-17 01:40:33 +0000 |
commit | 45221bd3e8ad6be56cb0ba471aa6a1d06e9efc0b (patch) | |
tree | b96cbd89cd521e0af0fdf69e1bdeb441b36096d5 | |
parent | 367b9c4766edf249352e525411ad7da73ef62c05 (diff) | |
download | gnuradio-45221bd3e8ad6be56cb0ba471aa6a1d06e9efc0b.tar.gz gnuradio-45221bd3e8ad6be56cb0ba471aa6a1d06e9efc0b.tar.bz2 gnuradio-45221bd3e8ad6be56cb0ba471aa6a1d06e9efc0b.zip |
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
-rw-r--r-- | gnuradio-core/src/lib/general/gr_complex_to_xxx.cc | 4 | ||||
-rwxr-xr-x | gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py | 20 |
2 files changed, 20 insertions, 4 deletions
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 <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; } 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) |