diff options
author | Martin Braun <martin.braun@ettus.com> | 2021-08-31 11:49:51 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-10-19 12:21:33 -0700 |
commit | 5ee6b828debbd60e03aff805bfd80e2030715a6f (patch) | |
tree | ef3a02b0c2dd055988c376f4bbf1c8e71ea6a330 /host/tests/math_test.cpp | |
parent | 91c10b66c23178e27bbff0e9173570c63e342736 (diff) | |
download | uhd-5ee6b828debbd60e03aff805bfd80e2030715a6f.tar.gz uhd-5ee6b828debbd60e03aff805bfd80e2030715a6f.tar.bz2 uhd-5ee6b828debbd60e03aff805bfd80e2030715a6f.zip |
uhd: math: Replace wrap-frequency math with a single function
In multiple places in the UHD code, we were doing the same calculation
for a wrapped frequency (wrap it into the first Nyquist zone). This math
was using boost::math, too. Instead of editing every instance, we create
a new function, uhd::math::wrap_frequency(), and replace all of its
separate implementations with this function. The new function also no
longer relies on boost::math::sign.
Diffstat (limited to 'host/tests/math_test.cpp')
-rw-r--r-- | host/tests/math_test.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/host/tests/math_test.cpp b/host/tests/math_test.cpp index 1fb01f5c1..12ede7f06 100644 --- a/host/tests/math_test.cpp +++ b/host/tests/math_test.cpp @@ -24,3 +24,11 @@ BOOST_AUTO_TEST_CASE(test_sign) BOOST_CHECK_EQUAL(uhd::math::sign(-2.3), -1); BOOST_CHECK_EQUAL(uhd::math::sign(0.0), 0); } + +BOOST_AUTO_TEST_CASE(test_wrap_frequency) +{ + BOOST_CHECK_EQUAL(uhd::math::wrap_frequency(10e6, 200e6), 10e6); + BOOST_CHECK_EQUAL(uhd::math::wrap_frequency(250e6, 200e6), 50e6); + BOOST_CHECK_EQUAL(uhd::math::wrap_frequency(120e6, 200e6), -80e6); + BOOST_CHECK_EQUAL(uhd::math::wrap_frequency(-250e6, 200e6), -50e6); +} |