commit f42d24e72023452c35c41767a7180aebee71b1d7
parent 2046a9e9e6235e2c6d86da0a65888733f1858122
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Tue, 8 Nov 2016 13:51:43 +0300
Tests for updated FIR filter
Diffstat:
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/tests/dsp_test.cpp b/tests/dsp_test.cpp
@@ -64,6 +64,26 @@ TEST(phasor)
CHECK(rms(v1 - v2) < 1.e-5);
}
+TEST(fir)
+{
+ const univector<double, 100> data = counter() + sequence(1, 2, -10, 100) + sequence(0, -7, 0.5);
+ const univector<double, 7> taps{ 1, 2, -2, 0.5, 0.0625, 4, -8 };
+
+ CHECK_EXPRESSION(fir(data, taps), 100, [&](size_t index) -> double {
+ double result = 0.0;
+ for (size_t i = 0; i < taps.size(); i++)
+ result += data.get(index - i, 0.0) * taps[i];
+ return result;
+ });
+
+ CHECK_EXPRESSION(short_fir(data, taps), 100, [&](size_t index) -> double {
+ double result = 0.0;
+ for (size_t i = 0; i < taps.size(); i++)
+ result += data.get(index - i, 0.0) * taps[i];
+ return result;
+ });
+}
+
int main()
{
println(library_version());