Accord.Tests.Math.FourierTransformTest.testFft C# (CSharp) Method

testFft() private static method

private static testFft ( int size ) : void
size int
return void
        private static void testFft(int size)
        {
            double[] re = randomReals(size);
            double[] im = randomReals(size);

            // Test double array overloads
            double[] inputreal = (double[])re.Clone();
            double[] inputimag = (double[])im.Clone();

            double[] refoutreal = new double[size];
            double[] refoutimag = new double[size];
            naiveDft(inputreal, inputimag, refoutreal, refoutimag, false);

            double[] actualoutreal = (double[])inputreal.Clone();
            double[] actualoutimag = (double[])inputimag.Clone();
            FourierTransform2.FFT(actualoutreal, actualoutimag, FourierTransform.Direction.Forward);

            double error = log10RmsErr(refoutreal, refoutimag, actualoutreal, actualoutimag);
            Assert.IsTrue(error < -12.9);


            // Test Complex overloads
            inputreal = (double[])re.Clone();
            inputimag = (double[])im.Clone();

            Complex[] input = inputreal.ToComplex(inputimag);
            FourierTransform2.FFT(input, FourierTransform.Direction.Forward);

            actualoutreal = input.Re();
            actualoutimag = input.Im();

            double newError = log10RmsErr(refoutreal, refoutimag, actualoutreal, actualoutimag);
            Assert.AreEqual(error, newError);
        }