commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 03/06: blocks: Add QA tests for the rotator


From: git
Subject: [Commit-gnuradio] [gnuradio] 03/06: blocks: Add QA tests for the rotator rotateN function which uses VOLK
Date: Tue, 28 Jan 2014 20:10:59 +0000 (UTC)

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

jcorgan pushed a commit to branch master
in repository gnuradio.

commit bc6c05b7ea8e039a413e68fae5b7c4bf298f885a
Author: Sylvain Munaut <address@hidden>
Date:   Sat Jan 25 22:56:06 2014 +0100

    blocks: Add QA tests for the rotator rotateN function which uses VOLK
    
    Signed-off-by: Sylvain Munaut <address@hidden>
---
 gr-blocks/lib/qa_rotator.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++
 gr-blocks/lib/qa_rotator.h  |  2 ++
 2 files changed, 46 insertions(+)

diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc
index 63cae39..c63d150 100644
--- a/gr-blocks/lib/qa_rotator.cc
+++ b/gr-blocks/lib/qa_rotator.cc
@@ -73,3 +73,47 @@ qa_rotator::t1()
       phase -= 2*M_PI;
   }
 }
+
+void
+qa_rotator::t2()
+{
+  static const unsigned        int N = 100000;
+
+  gr::blocks::rotator r;
+  gr_complex *input  = new gr_complex[N];
+  gr_complex *output = new gr_complex[N];
+
+  double phase_incr = 2*M_PI / 1003;
+  double phase = 0;
+
+  r.set_phase(gr_complex(1,0));
+  r.set_phase_incr(gr_expj(phase_incr));
+
+  // Generate a unity sequence
+  for(unsigned i = 0; i < N; i++)
+    input[i] = gr_complex(1.0f, 0.0f);
+
+  // Rotate it
+  r.rotateN(output, input, N);
+
+  // Compare with expected result
+  for(unsigned i = 0; i < N; i++) {
+    gr_complex expected = gr_expj(phase);
+    gr_complex actual   = output[i];
+
+#if 0
+    float evm = error_vector_mag(expected, actual);
+    printf("[%6d] expected: (%8.6f, %8.6f)  actual: (%8.6f, %8.6f)  evm: 
%8.6f\n",
+          i, expected.real(), expected.imag(), actual.real(), actual.imag(), 
evm);
+#endif
+
+    CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001);
+
+    phase += phase_incr;
+    if(phase >= 2*M_PI)
+      phase -= 2*M_PI;
+  }
+
+  delete[] output;
+  delete[] input;
+}
diff --git a/gr-blocks/lib/qa_rotator.h b/gr-blocks/lib/qa_rotator.h
index 575ea50..06214bc 100644
--- a/gr-blocks/lib/qa_rotator.h
+++ b/gr-blocks/lib/qa_rotator.h
@@ -30,10 +30,12 @@ class qa_rotator : public CppUnit::TestCase
 {
   CPPUNIT_TEST_SUITE(qa_rotator);
   CPPUNIT_TEST(t1);
+  CPPUNIT_TEST(t2);
   CPPUNIT_TEST_SUITE_END();
 
  private:
   void t1();
+  void t2();
 };
 
 #endif /* _QA_GR_ROTATOR_H_ */



reply via email to

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