Industrial Data Science
in C# and .NET:
Simple. Fast. Reliable.
 
 

ILNumerics - Technical Computing

Modern High Performance Tools for Technical

Computing and Visualization in Industry and Science

tgt

Fast Fourier Transformation (FFT) in .NET (C# and Visual Basic)

The recommended way of computing FFTs is to utilize the static builtin functions of the ILMath class. They operate on all arrays with elements of any floating point type (double, float, complex, fcomplex). Fourier transforms can be computed for 1, 2 ... n dimensions. All functions are listed in the following table; learn more in the ILNumerics Class Reference.

 
1 - dimensional Fourier Transforms
fft(A) Computes the one-dimensional fft on columns of A. If A is a n-dimensional array, the operation is performed along the first non-singleton dimension and repeated for all subsequent dimensions. The output will be a complex array, having the same size as A. For A of element type double or float the result will be complex hermitian.
fft(A,dim) Same as ILMath.fft(A), but operating along the dimension with index 'dim'.
ifft(A) Computes the one-dimensional inverse fft on columns of A. The function is the counterpart to ILMath.fft(A). Computationally the algorithm is equivalent to the forward transform, introducing a sign change in the exponent of the complex fourier operator and a scaling factor. This makes sure the equation A = ifft(fft(A)) holds true.
ifft(A,dim) Computes the one-dimensional inverse fft along the 'dim' dimension of A. The function is the counterpart to ILMath.fft(A,dim).
ifftsym(A) Computes the one-dimensional inverse fft along the first non-singleton dimension of A. A must be complex hermitian. This, f.e. is true, if A is the result of a FFT on real data. Since the result of transforming complex hermitian arrays is concidered real anyway, the function returns a real array directly. Internally the computation is speed up by ommiting the complex parts accordingly.
ifftsym(A,dim) Computes the one-dimensional inverse fft of complex hermitian data along the dimension 'dim'. This function returns the real part as array and corresponds to ILMath.ifftsym(A).
2 - dimensional Fourier Transforms
fft2(A) Computes the two-dimensional fft on columns of A. If A is a n-dimensional array, the operation is performed along the first two dimensions and repeated for all subsequent higher dimensions. The output will be a complex array, having the same size as A. For A of element type double or float the result will be complex hermitian.
fft2(A,m,n) Same as ILMath.fft(A) - optionally resizing the array before transformation. m specifies the length of columns and n the length of rows of the transformation array. If the corresponding dimension of A is smaller than m or n, the dimension will be padded with zeros. If m or n is smaller than the corresponding dimension of A, the dimension will be truncated. The result will have the size (m by n by [higher order dimensions of A]). If A is a n-dimensional array, the sizes of higher order dimensions (3...n) are left untouched and the transformation is repeated for them.
ifft2(A) Computes the two-dimensional inverse fft on the first two dimensions of A. The function is the counterpart to ILMath.fft2(A).
ifft2(A,m,n) Computes the two-dimensional inverse fft for the resized version of A. This function is the counterpart to ILMath.fft2(A,m,n). The result will be complex.
ifft2sym(A) Computes the two-dimensional inverse fft along the first two dimensions of A. A must be complex hermitian in those dimensions. This, f.e. is true, if A is the result of a two-dimensional FFT of real array elements (double, float).
ifft2sym(A,m,n) Computes the two-dimensional inverse fft of complex hermitian data in A along the first two dimensions. This function returns a real array.
n - dimensional Fourier Transforms
fftn(A) Computes the n-dimensional fft on the first n dimensions of A. If n is less than the number of dimensions of A, the operation is repeated for all subsequent higher dimensions. The output will be a complex array, having the same size as A. For A of element type double or float the result will be complex hermitian in the first n dimensions.
fftn(A,int[] dims) Same as ILMath.fftn(A) - optionally resizing the array before transformation. dims specifies the size of the dimensions of the transformation array. If the size specifier is smaller than the corresponding dimension length of A, the dimension is truncated, otherwise the data are zero padded. The length of dim must match the number of dimensions of A. ILMath.fftn(A,A.Size.ToIntArray()) corresponds to ILMath.fftn(A).
ifftn(A) Computes the n dimensional inverse fft on first n dimensions of A. The function is the counterpart to ILMath.fftn(A).
ifftn(A,int[] dims) Computes the n dimensional inverse fft for the resized version of A. This function is the counterpart to ILMath.fftn(A,params int[] dims). The result will be complex.
ifftnsym(A) Computes the n dimensional inverse fft along the first n dimensions of A. A must be complex hermitian in those dimensions. This, f.e. is true, if A is the result of a n-dimensional FFT on real data elements (double, float). The function returns an array of real elements.
ifftnsym(A,int[] dims) Computes the n dimensional inverse fft of complex hermitian data in A along the first n dimensions. This function returns a real array. One has to make sure, the resized version of A is complex hermitian. Otherwise the result is undefined.