Esempio n. 1
0
        static void Example1D()
        {
            double[]  input  = new double[24];
            Complex[] output = new Complex[input.GetLength(input.Rank - 1) / 2 + 1];
            double[]  inOut  = new double[input.Length];

            for (int i = 0; i < input.Length; i++)
            {
                input[i] = Math.Sin(i * 2 * Math.PI * 128 / input.Length);
            }

            using (var pinIn = new PinnedArray <double>(input))
                using (var pinOut = new PinnedArray <Complex>(output))
                    using (var in1Out = new PinnedArray <double>(inOut))
                    {
                        Console.WriteLine(pinIn.GetLength(input.Rank - 1) / 2 + 1);
                        Console.WriteLine(pinOut.GetLength(input.Rank - 1));

                        Console.WriteLine(input.Length);
                        Console.WriteLine(output.Length);

                        DFT.FFT(pinIn, pinOut);
                        DFT.IFFT(pinOut, in1Out);
                    }

            Console.WriteLine("Input");

            for (int i = 0; i < input.Length; i++)
            {
                Console.WriteLine(Math.Sin(i * 2 * Math.PI * 128 / input.Length));
            }

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("output");
            for (int i = 0; i < inOut.Length; i++)
            {
                Console.WriteLine(inOut[i] / input.Length);
            }
        }