Beispiel #1
0
        public static List <complex> ForwardDiscreteFourierTransform(List <complex> Signal)
        {
            int N = Signal.Count;

            List <complex> OutSignal = new List <complex>();

            for (int i = 0; i < N; i++)
            {
                OutSignal.Add(new complex(0));

                for (int j = 0; j < N; j++)
                {
                    var w = ComplexConverter.FromRadians(1, (-2 * Math.PI * i * j) / N);
                    OutSignal[i] += w * Signal[j];
                }
            }

            return(OutSignal);
        }
Beispiel #2
0
        public static List <complex> InverseFourierTransform(List <complex> Signal)
        {
            if (Signal.Count == 1)
            {
                return(Signal);
            }

            var N = Signal.Count;

            var Even = Signal.Where((item, index) => index % 2 == 0).ToList();
            var Odd  = Signal.Where((item, index) => index % 2 != 0).ToList();

            var yEven = ForwardFourierTransform(Even);
            var yOdd  = ForwardFourierTransform(Odd);


            var Y = new List <complex>();

            for (int i = 0; i < N; i++)
            {
                Y.Add(new complex(0, 0));
            }

            var W = new List <complex>();

            for (int i = 0; i < N; i++)
            {
                double alpha = 2 * Math.PI * i / N;
                W.Add(ComplexConverter.FromRadians(1, alpha));
            }

            for (int i = 0; i < N / 2; i++)
            {
                Y[i]         = (yEven[i] + W[i] * yOdd[i]) / N;
                Y[i + N / 2] = (yEven[i] - W[i] * yOdd[i]) / N;
            }

            return(Y);
        }