Exemplo n.º 1
0
        public void ConvolutionBruteForceTest()
        {
            var target   = new WWConvolution();
            var h        = new WWComplex [] { new WWComplex(2, 0), WWComplex.Unity() };
            var x        = new WWComplex[] { WWComplex.Unity(), WWComplex.Unity() };
            var actual   = target.ConvolutionBruteForce(h, x);
            var expected = new WWComplex[] { new WWComplex(2, 0), new WWComplex(3, 0), WWComplex.Unity() };

            Assert.IsTrue(Compare(actual, expected));
        }
Exemplo n.º 2
0
        public void ConvolutionBruteForceTest_p690()
        {
            var target   = new WWConvolution();
            var h        = WWComplex.FromRealArray(new double[] { 1, 1, 1, 1, 1, 2, 2, 2 });
            var x        = WWComplex.FromRealArray(new double[] { 1, 1, 1, 1 });
            var actual   = target.ConvolutionBruteForce(h, x);
            var expected = WWComplex.FromRealArray(new double[] { 1, 2, 3, 4, 4, 5, 6, 7, 6, 4, 2 });

            Assert.IsTrue(Compare(actual, expected));
        }
Exemplo n.º 3
0
        static void Ex02()
        {
            var h = new WWComplex[] {
                new WWComplex(1, 0),
                new WWComplex(-1, 0)
            };

            var x = new WWComplex[] {
                new WWComplex(1, 0),
                new WWComplex(2, 0),
                new WWComplex(3, 0),
                new WWComplex(1, 0),
                new WWComplex(-2, 0),
                new WWComplex(1, 0),
                new WWComplex(-1, 0),
                new WWComplex(-2, 0),
                new WWComplex(1, 0),
                new WWComplex(3, 0),
            };

            var conv = new WWConvolution();

            var y = conv.ConvolutionBruteForce(h, x);

            Print("h ", h);
            Print("x ", x);
            Print("y ", y);

            var y2 = conv.ConvolutionFft(h, x);

            Print("y2", y2);

            Console.WriteLine("distance(y, y2)={0}", WWComplex.AverageDistance(y, y2));

            var y3 = conv.ConvolutionContinuousFft(h, x);

            Print("y3", y3);

            Console.WriteLine("distance(y, y3)={0}", WWComplex.AverageDistance(y, y3));
        }