Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ReportBuilder reportBuilder = new ReportBuilder();
            ITransformer  dft           = new DftTransformer();
            ITransformer  fft           = new FFTTransformer();
            ISignal       sig           = new Signal((Function)((x) => Math.Sin(2 * x) + Math.Cos(2 * x)), Math.PI);
            ReportBuilder rpb           = new ReportBuilder();

            FunctionTableItem[] temp;

            temp = sig.GenerateSample(32, Math.PI);
            rpb.AddInfo(temp, ValueIs.Real, false);


            temp = dft.Transform(sig.Sample);
            rpb.AddInfo(temp, ValueIs.Magnitude, true);
            rpb.AddString(String.Format("Discrete Fourier transform. {0} Iterations", dft.ActionCount));

            temp = dft.Inverse(temp);
            rpb.AddInfo(temp, ValueIs.Real, true);
            rpb.AddString(String.Format("Inverse discrete Fourier transform. {0} Iterations", dft.ActionCount));

//            rpb.AddInfo(temp, ValueIs.Phase, true);
//            rpb.AddString("phase-frequency spectrum");


            temp = fft.Transform(sig.Sample);
            rpb.AddInfo(temp, ValueIs.Magnitude, true);
            rpb.AddString(String.Format("Fast Fourier transform. {0} Iterations", fft.ActionCount));

            temp = fft.Inverse(temp);
            rpb.AddInfo(temp, ValueIs.Real, true);
            rpb.AddString(String.Format("Inverse fast Fourier transform. {0} Iterations", fft.ActionCount));

//            temp = dft.Inverse(temp);
//            rpb.AddInfo(temp, ValueIs.Real, true);
//            rpb.AddString(String.Format("Inverse discrete Fourier transform. {0} Iterations", dft.ActionCount));


//            rpb.AddInfo(temp, ValueIs.Phase, true);
//            rpb.AddString("phase-frequency spectrum");

            rpb.Show();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ReportBuilder reportBuilder = new ReportBuilder();
            ITransformer dft = new DftTransformer();
            ITransformer fft = new FFTTransformer();
            ISignal sig = new Signal((Function)((x) => Math.Sin(2*x) + Math.Cos(2*x)), Math.PI);
            ReportBuilder rpb = new ReportBuilder();
            FunctionTableItem[] temp;

            temp = sig.GenerateSample(32, Math.PI);
            rpb.AddInfo(temp, ValueIs.Real, false);

            temp = dft.Transform(sig.Sample);
            rpb.AddInfo(temp, ValueIs.Magnitude, true);
            rpb.AddString(String.Format("Discrete Fourier transform. {0} Iterations", dft.ActionCount));

            temp = dft.Inverse(temp);
            rpb.AddInfo(temp, ValueIs.Real, true);
            rpb.AddString(String.Format("Inverse discrete Fourier transform. {0} Iterations", dft.ActionCount));

            //            rpb.AddInfo(temp, ValueIs.Phase, true);
            //            rpb.AddString("phase-frequency spectrum");

            temp = fft.Transform(sig.Sample);
            rpb.AddInfo(temp, ValueIs.Magnitude, true);
            rpb.AddString(String.Format("Fast Fourier transform. {0} Iterations", fft.ActionCount));

            temp = fft.Inverse(temp);
            rpb.AddInfo(temp, ValueIs.Real, true);
            rpb.AddString(String.Format("Inverse fast Fourier transform. {0} Iterations", fft.ActionCount));

            //            temp = dft.Inverse(temp);
            //            rpb.AddInfo(temp, ValueIs.Real, true);
            //            rpb.AddString(String.Format("Inverse discrete Fourier transform. {0} Iterations", dft.ActionCount));

            //            rpb.AddInfo(temp, ValueIs.Phase, true);
            //            rpb.AddString("phase-frequency spectrum");

            rpb.Show();
        }