/// <summary> /// A static transformation method. The length is the nearest power of two that is not greater than the input length. /// Returns the full result. /// </summary> public static IArrayView <double> TransformRaw(IArrayView <double> input, FFTOutputType outputType = FFTOutputType.Power, WindowType windowType = WindowType.Rectangular) { int count = input.Count.NearestPowerOfTwo(false); var fft = new RealFourierTransformation(); double[] window = windowType.Apply(input.Take(count), count).ToArray(), real, imag; fft.TransformForward(window, out real, out imag); if (outputType == FFTOutputType.Imaginary) { return(imag.AsIArray()); } if (outputType == FFTOutputType.Power) { for (int i = 0; i < real.Length; i++) { real[i] = Math.Sqrt(real[i] * real[i] + imag[i] * imag[i]); } } return(real.AsIArray()); }
/// <summary> /// A static transformation method. The length is the nearest power of two that is not greater than the input length. /// Returns the full result. /// </summary> public static IArrayView<double> TransformRaw(IArrayView<double> input, FFTOutputType outputType = FFTOutputType.Power, WindowType windowType = WindowType.Rectangular) { int count = input.Count.NearestPowerOfTwo(false); var fft = new RealFourierTransformation(); double[] window = windowType.Apply(input.Take(count), count).ToArray(), real, imag; fft.TransformForward(window, out real, out imag); if (outputType == FFTOutputType.Imaginary) return imag.AsIArray(); if (outputType == FFTOutputType.Power) for (int i = 0; i < real.Length; i++) real[i] = Math.Sqrt(real[i] * real[i] + imag[i] * imag[i]); return real.AsIArray(); }