Beispiel #1
0
        public void TestAmplitudeToComplex()
        {
            var input  = new[] { 1.0, 2, 3 };
            var output = Dsp.AmplitudeToComplex(input).ToReadOnlyList();

            Complex[] target = { Complex.One, 2, 3 };
            FilterAssert.ListsAreEqual(output, target);

            Assert.That(Dsp.AmplitudeToComplex(new List <double>()).ToReadOnlyList().Count == 0);

            Assert.Throws <ArgumentNullException>(() => Dsp.AmplitudeToComplex(null));
        }
Beispiel #2
0
        public void TestCircularShift()
        {
            var x = new[] { 1.0, 2, 3, 4, 5, 6, 7, 8 };

            var output = Dsp.CircularShift(x, 0).ToReadOnlyList();

            FilterAssert.ListsAreEqual(x, output);

            output = Dsp.CircularShift(x, -2).ToReadOnlyList();
            FilterAssert.ListsAreEqual(new[] { 7, 8, 1.0, 2, 3, 4, 5, 6 }, output);

            output = Dsp.CircularShift(x, 2).ToReadOnlyList();
            FilterAssert.ListsAreEqual(new[] { 3, 4, 5, 6, 7, 8, 1.0, 2 }, output);

            Assert.That(Dsp.CircularShift(new List <double>(), 2).ToReadOnlyList().Count == 0);
            Assert.Throws <ArgumentNullException>(() => Dsp.CircularShift <double>(null, 2).ToReadOnlyList());
        }
Beispiel #3
0
        public void TestGenerateSlope()
        {
            var x = new[] { 1.0, 2, 3, 4, 5, 6, 7, 8 };

            var output = Dsp.GenerateSlope(x, 2, 7, -10, 20).ToReadOnlyList();

            Assert.That(output.Count == x.Length);
            Assert.That(output[0] == -10);
            Assert.That(output[output.Count - 1] == 20);
            FilterAssert.ListIsMonotonouslyRising(output);

            var output2 = Dsp.GenerateSlope(x, 7, 2, 20, -10).ToReadOnlyList();

            FilterAssert.ListsAreEqual(output, output2);

            Assert.That(Dsp.GenerateSlope(new List <double>(), 2, 7, 10, 20).ToReadOnlyList().Count == 0);
            Assert.Throws <ArgumentNullException>(() => Dsp.GenerateSlope(null, 2, 7, 10, 20).ToReadOnlyList());
        }