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); }
private static ComplexFloat[] FFT(ComplexFloat[] complexFloats, bool newOmegas = true) { int n = complexFloats.Length; //if (!Helpers.CheckIfPowerOfTwo(n)) //{ // throw new ArgumentException("Array length must e a power of 2!"); //} int k = (int)Math.Log2(n); if (newOmegas) { omegas = OmegaCalculator.GenerateOmegas(k); } return(FFTRecursive(complexFloats, k)); }