summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2014-01-25 22:56:06 +0100
committerSylvain Munaut <tnt@246tNt.com>2014-01-28 20:35:18 +0100
commitbc6c05b7ea8e039a413e68fae5b7c4bf298f885a (patch)
treed5be6bbc3f0aa63d43250fe3a6cb628a5e00d70b
parente00ff5b4d38815da48aa958acb41588851497cb5 (diff)
blocks: Add QA tests for the rotator rotateN function which uses VOLK
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r--gr-blocks/lib/qa_rotator.cc44
-rw-r--r--gr-blocks/lib/qa_rotator.h2
2 files changed, 46 insertions, 0 deletions
diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc
index 63cae39ca8..c63d150113 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 575ea506c7..06214bc2fc 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_ */