示例#1
0
        public static ComplexFloat[,] FFT(float[,] input)
        {
            int rows    = input.GetLength(0);
            int columns = input.GetLength(1);

            int k = (int)Math.Log2(rows >= columns ? rows : columns);

            omegas = OmegaCalculator.GenerateOmegas(k);

            if (!Helpers.CheckIfPowerOfTwo(rows) || !Helpers.CheckIfPowerOfTwo(columns))
            {
                throw new ArgumentException("Array length must be a power of 2!");
            }

            ComplexFloat[,] result = new ComplexFloat[rows, columns];
            Parallel.For(0, rows, (i) =>
                         //for(int i = 0; i < rows; i++)
            {
                ComplexFloat[] tmpRow = FFT(input.GetRow(i), false);
                for (int j = 0; j < columns; j++)
                {
                    result[i, j] = tmpRow[j];
                }
            });

            Parallel.For(0, columns, (i) =>
            {
                ComplexFloat[] tmpCol = FFT(result.GetCol(i), false);
                for (int j = 0; j < rows; j++)
                {
                    result[j, i] = tmpCol[j];
                }
            });
            return(result);
        }
示例#2
0
        public static float[,] IFFT(ComplexFloat[,] input)
        {
            int rows    = input.GetLength(0);
            int columns = input.GetLength(1);

            ComplexFloat[,] result = new ComplexFloat[rows, columns];
            ComplexFloat[] tmpRow = new ComplexFloat[columns];
            ComplexFloat[] tmpCol = new ComplexFloat[rows];
            for (int i = 0; i < rows; i++)
            {
                tmpRow = IFFT(input.GetRow(i));
                for (int j = 0; j < columns; j++)
                {
                    result[i, j] = tmpRow[j];
                }
            }
            for (int i = 0; i < columns; i++)
            {
                tmpCol = IFFT(result.GetCol(i));
                for (int j = 0; j < rows; j++)
                {
                    result[j, i] = tmpCol[j];
                }
            }
            return(result.Convert());
        }
示例#3
0
        public static float[,] IFFT(ComplexFloat[,] input)
        {
            int rows    = input.GetLength(0);
            int columns = input.GetLength(1);

            ComplexFloat[,] result = new ComplexFloat[rows, columns];
            Parallel.For(0, rows, (i) =>
            {
                ComplexFloat[] tmpRow = IFFT(input.GetRow(i));
                for (int j = 0; j < columns; j++)
                {
                    result[i, j] = tmpRow[j];
                }
            });
            Parallel.For(0, columns, (i) =>
            {
                ComplexFloat[] tmpCol = IFFT(result.GetCol(i));
                for (int j = 0; j < rows; j++)
                {
                    result[j, i] = tmpCol[j];
                }
            });
            return(result.Convert());
        }