Beispiel #1
0
        public void Test60HzBlockFilterTaps()
        {
            List <double> input;
            List <double> expectedOutput;

            GetInputAndExpected(out input, out expectedOutput);

            var filter = new BlockIirFilter(A60, B60);

            var segmentLength = input.Count / 100;

            var actualOutput = new List <double>(input.Count);

            var rangeStart = 0;

            for (int i = 0; i < 100 - 1; ++i)
            {
                actualOutput.AddRange(filter.Filter(input.GetRange(rangeStart, segmentLength).ToArray()));
                rangeStart += segmentLength;
            }

            actualOutput.AddRange(filter.Filter(input.GetRange(rangeStart, input.Count - rangeStart).ToArray()));

            var equal = expectedOutput.GetRange(1, expectedOutput.Count - 1).ContentsEqual(actualOutput.GetRange(1, actualOutput.Count - 1), .000001);

            Assert.IsTrue(equal);
        }
Beispiel #2
0
        public void BasicTest()
        {
            var array2 = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };

            var target = new BlockIirFilter(_a, _b);



            target.Filter(array2);
        }
Beispiel #3
0
        public void TestBlockIir()
        {
            var input = GetInput3();

            var filter = new BlockIirFilter(_a, _b);

            var actual   = filter.Filter(input.ToArray()).Skip(58);
            var expected = GetOutput3().Skip(58);

            var equal = expected.ContentsEqual(actual, .0001);

            if (!equal)
            {
                expected.Print();
                Console.WriteLine();
                actual.Print();
            }

            Assert.IsTrue(equal);
        }
Beispiel #4
0
        public void TestBlockIirAllZeros()
        {
            var input = Enumerable.Repeat(0.0, 300);

            var filter = new BlockIirFilter(_a, _b);

            var actual   = filter.Filter(input.ToArray());
            var expected = input.ToArray();

            var equal = expected.ContentsEqual(actual, .0001);

            if (!equal)
            {
                expected.Print();
                Console.WriteLine();
                actual.Print();
            }

            Assert.IsTrue(equal);
        }