Exemplo n.º 1
0
        public void Complex_Symmetry_RealEven_RealEven()
        {
            // h(t) real-valued even <=> H(f) real-valued even-with-offset

            int numSamples = 32;
            int length     = 2 * numSamples;

            double[] data = new double[length];

            for (int i = 0; i < length; i += 2)
            {
                double z = (double)(i - numSamples) / numSamples;
                data[i]     = 1.0 / (z * z + 1.0);
                data[i + 1] = 0.0;
            }

            ComplexTestTimeEven(data);

            cft.Convention = TransformationConvention.Matlab; // so we can check MATLAB consistency
            cft.TransformForward(data);

            ComplexTestImagZero(data);
            ComplexTestFreqEven(data);

            /* Compare With MATLAB:
             * samples_t = 1.0 ./ (([-16:1:15] ./ 16) .^ 2 + 1.0)
             * samples_f = fft(samples_t)
             */

            Assert.AreEqual(25.128, data[0 * 2], 0.001, "MATLAB 1");
            Assert.AreEqual(-3.623, data[1 * 2], 0.001, "MATLAB 2");
            Assert.AreEqual(-0.31055, data[2 * 2], 0.00001, "MATLAB 3");

            Assert.AreEqual(-0.050611, data[6 * 2], 0.000001, "MATLAB 7");
            Assert.AreEqual(-0.03882, data[7 * 2], 0.00001, "MATLAB 8");
            Assert.AreEqual(-0.031248, data[8 * 2], 0.000001, "MATLAB 9");

            Assert.AreEqual(-0.017063, data[13 * 2], 0.000001, "MATLAB 14");
            Assert.AreEqual(-0.016243, data[14 * 2], 0.000001, "MATLAB 15");
            Assert.AreEqual(-0.015777, data[15 * 2], 0.000001, "MATLAB 16");
        }
Exemplo n.º 2
0
 public static void FFT(Complex[] xdata)
 {
     Debug.WriteLine("FFT data:" + xdata.Length);
     cft.TransformForward(xdata);
 }