kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit 0484cdc51368e0ebe1950b477e7cfb51ebc662a2
parent 7998955b98415bb1be08162057be18cde93347ea
Author: [email protected] <[email protected]>
Date:   Tue,  3 Dec 2019 13:55:55 +0000

Tests for absminof, absmaxof

Diffstat:
Mtests/dsp_test.cpp | 22+++++++++++-----------
Mtests/unit/base/reduce.cpp | 47+++++++++++++++++++++++++++--------------------
2 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/tests/dsp_test.cpp b/tests/dsp_test.cpp @@ -262,23 +262,23 @@ TEST(amp_to_dB) { testo::eplison_scope<void> eps(1000); - CHECK(kfr::amp_to_dB(2.0) == fbase(6.0205999132796239042747778944899)); - CHECK(kfr::amp_to_dB(-2.0) == fbase(6.0205999132796239042747778944899)); - CHECK(kfr::amp_to_dB(1.0) == fbase(0)); - CHECK(kfr::amp_to_dB(-1.0) == fbase(0)); - CHECK(kfr::amp_to_dB(0.5) == fbase(-6.0205999132796239042747778944899)); - CHECK(kfr::amp_to_dB(-0.5) == fbase(-6.0205999132796239042747778944899)); - CHECK(kfr::amp_to_dB(0.0) == fbase(-HUGE_VAL)); + CHECK(kfr::amp_to_dB(fbase(2.0)) == fbase(6.0205999132796239042747778944899)); + CHECK(kfr::amp_to_dB(fbase(-2.0)) == fbase(6.0205999132796239042747778944899)); + CHECK(kfr::amp_to_dB(fbase(1.0)) == fbase(0)); + CHECK(kfr::amp_to_dB(fbase(-1.0)) == fbase(0)); + CHECK(kfr::amp_to_dB(fbase(0.5)) == fbase(-6.0205999132796239042747778944899)); + CHECK(kfr::amp_to_dB(fbase(-0.5)) == fbase(-6.0205999132796239042747778944899)); + CHECK(kfr::amp_to_dB(fbase(0.0)) == fbase(-HUGE_VAL)); } TEST(dB_to_amp) { testo::eplison_scope<void> eps(1000); - CHECK(kfr::dB_to_amp(-HUGE_VAL) == fbase(0.0)); - CHECK(kfr::dB_to_amp(0.0) == fbase(1.0)); - CHECK(kfr::dB_to_amp(6.0205999132796239042747778944899) == fbase(2.0)); - CHECK(kfr::dB_to_amp(-6.0205999132796239042747778944899) == fbase(0.5)); + CHECK(kfr::dB_to_amp(fbase(-HUGE_VAL)) == fbase(0.0)); + CHECK(kfr::dB_to_amp(fbase(0.0)) == fbase(1.0)); + CHECK(kfr::dB_to_amp(fbase(6.0205999132796239042747778944899)) == fbase(2.0)); + CHECK(kfr::dB_to_amp(fbase(-6.0205999132796239042747778944899)) == fbase(0.5)); } TEST(delay) diff --git a/tests/unit/base/reduce.cpp b/tests/unit/base/reduce.cpp @@ -13,34 +13,41 @@ inline namespace CMT_ARCH_NAME TEST(reduce) { + testo::eplison_scope<void> e(100); { - univector<float, 5> a({ 1, 2, 3, 4, 5 }); - CHECK(sum(a) == 15); - CHECK(mean(a) == 3); - CHECK(minof(a) == 1); + univector<float, 6> a({ 1, 2, 3, 4, 5, -9 }); + CHECK(sum(a) == 6); + CHECK(mean(a) == 1); + CHECK(minof(a) == -9); CHECK(maxof(a) == 5); - CHECK(sumsqr(a) == 55); - CHECK(rms(a) == 3.316624790355399849115f); - CHECK(product(a) == 120); + CHECK(absminof(a) == 1); + CHECK(absmaxof(a) == 9); + CHECK(sumsqr(a) == 136); + CHECK(rms(a) == 4.760952285695233f); + CHECK(product(a) == -1080); } { - univector<double, 5> a({ 1, 2, 3, 4, 5 }); - CHECK(sum(a) == 15); - CHECK(mean(a) == 3); - CHECK(minof(a) == 1); + univector<double, 6> a({ 1, 2, 3, 4, 5, -9 }); + CHECK(sum(a) == 6); + CHECK(mean(a) == 1); + CHECK(minof(a) == -9); CHECK(maxof(a) == 5); - CHECK(sumsqr(a) == 55); - CHECK(rms(a) == 3.316624790355399849115); - CHECK(product(a) == 120); + CHECK(absminof(a) == 1); + CHECK(absmaxof(a) == 9); + CHECK(sumsqr(a) == 136); + CHECK(rms(a) == 4.760952285695233); + CHECK(product(a) == -1080); } { - univector<int, 5> a({ 1, 2, 3, 4, 5 }); - CHECK(sum(a) == 15); - CHECK(mean(a) == 3); - CHECK(minof(a) == 1); + univector<int, 6> a({ 1, 2, 3, 4, 5, -9 }); + CHECK(sum(a) == 6); + CHECK(mean(a) == 1); + CHECK(minof(a) == -9); CHECK(maxof(a) == 5); - CHECK(sumsqr(a) == 55); - CHECK(product(a) == 120); + CHECK(absminof(a) == 1); + CHECK(absmaxof(a) == 9); + CHECK(sumsqr(a) == 136); + CHECK(product(a) == -1080); } } } // namespace CMT_ARCH_NAME