Ejemplo n.º 1
0
        public void TestAllZeros()
        {
            //Arrange
            const int size = 1024;

            Complex[] array    = new Complex[size];
            Complex[] expected = new Complex[size];
            for (int i = 0; i < array.Length; i++)
            {
                expected[i] = new Complex()
                {
                    realPart = 0, imaginaryPart = 0
                };
                array[i] = new Complex()
                {
                    realPart = 0, imaginaryPart = 0
                };
            }

            //Act
            var result = Extensions.MakeFFT(array, array.Length, 0, 1);

            //Assert
            Assert.IsTrue(ComplexComparer.AreEqual(result, expected));
        }
Ejemplo n.º 2
0
        public void TestSequence()
        {
            //Arrange
            const int size = 4;

            Complex[] array    = new Complex[size];
            Complex[] expected =
            {
                new Complex()
                {
                    realPart = 10, imaginaryPart = 10
                },
                new Complex()
                {
                    realPart = 0, imaginaryPart = -4
                },
                new Complex()
                {
                    realPart = -2, imaginaryPart = -2
                },
                new Complex()
                {
                    realPart = -4, imaginaryPart = 0
                }
            };
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = new Complex()
                {
                    realPart = i + 1, imaginaryPart = i + 1
                };
            }

            //Act
            var result = Extensions.MakeFFT(array, array.Length, 0, 1);

            //Assert
            Assert.IsTrue(ComplexComparer.AreEqual(result, expected));
        }
Ejemplo n.º 3
0
        public void TestOnesAndZeros()
        {
            //Arrange
            const int size = 1024;

            Complex[] array    = new Complex[size];
            Complex[] expected = new Complex[size];
            for (int i = 0; i < array.Length; i++)
            {
                expected[i] = new Complex()
                {
                    realPart = 0, imaginaryPart = 0
                };
                if (i % 2 == 0)
                {
                    array[i] = new Complex()
                    {
                        realPart = 1, imaginaryPart = 0
                    };
                }
                else
                {
                    array[i] = new Complex()
                    {
                        realPart = 0, imaginaryPart = 0
                    };
                }
            }
            expected[0].realPart        = size / 2;
            expected[size / 2].realPart = size / 2;

            //Act
            var result = Extensions.MakeFFT(array, array.Length, 0, 1);

            //Assert
            Assert.IsTrue(ComplexComparer.AreEqual(result, expected));
        }