MF_FFT MD_FFT ME_FFT
MFb_FFT MDb_FFT MEb_FFT
MF_FFTtoC MD_FFTtoC ME_FFTtoC
MFb_FFTtoC MDb_FFTtoC MEb_FFTtoC
MCF_FFT MCD_FFT MCE_FFT
MCFb_FFT MCDb_FFT MCEb_FFT
Functiontwo-dimensional Fast Fourier Transform
Syntax C/C++#include <MFstd.h>
void MF_FFT( fMatrix MY, fMatrix MX, ui ht, ui len, int dir );
void MCF_FFT( cfMatrix MY, cfMatrix MX, ui ht, ui len, int dir );
void MF_FFTtoC( cfMatrix MY, fMatrix MX, ui ht, ui len );
void MFb_FFT( fMatrix MY, fMatrix MX, ui ht, ui len, int dir, fVector Buf );
void MCFb_FFT( cfMatrix MY, cfMatrix MX, ui ht, ui len, int dir, cfVector Buf );
void MFb_FFTtoC( cfMatrix MY, fMatrix MX, ui ht, ui len, cfVector Buf );
C++ MatObj#include <OptiVec.h>
void matrix<T>::FFT( const matrix<T>& MX, int dir );
void matrix<complex<T> >::FFT( const matrix<complex<T> >& MX, int dir );
void matrix<complex<T> >::FFTtoC( const matrix<T>& MX );
void matrix<T>::b_FFT( const matrix<T>& MX, int dir, vector<T>& Buf );
void matrix<complex<T> >::b_FFT( const matrix<complex<T> > MX, int dir, vector<complex<T> >&Buf );
void matrix<complex<T> >::b_FFTtoC( const matrix<T> MX, vector<complex<T>>& Buf );
Pascal/Delphiuses MFstd;
procedure MF_FFT( MY, MX:fMatrix; ht, len:UIntSize; dir:Integer );
procedure MCF_FFT( MY, MX:cfMatrix; ht, len:UIntSize; dir:Integer );
procedure MF_FFTtoC( MY:cfMatrix; MX:fMatrix; ht, len:UIntSize );
procedure MFb_FFT( MY, MX:fMatrix; ht, len:UIntSize; dir:Integer; Buf:fVector );
procedure MCFb_FFT( MY, MX:cfMatrix; ht, len:UIntSize; dir:Integer; Buf:cfVector );
procedure MFb_FFTtoC( MY:cfMatrix; MX:fMatrix; ht, len:UIntSize; Buf:cfVector );
CUDA function C/C++#include <cudaMFstd.h>
int cudaMF_FFT( fMatrix d_MY, fMatrix d_MX, ui ht, ui len, int dir );
int cudaMCF_FFT( cfMatrix d_MY, cfMatrix d_MX, ui ht, ui len, int dir );
int cudaMF_FFTtoC( cfMatrix d_MY, fMatrix d_MX, ui ht, ui len );
void MFcu_FFT( fMatrix h_MY, fMatrix h_MX, ui ht, ui len, int dir );
void MCFcu_FFT( cfMatrix h_MY, cfMatrix h_MX, ui ht, ui len, int dir );
void MFcu_FFTtoC( cfMatrix h_MY, fMatrix h_MX, ui ht, ui len );
CUDA function Pascal/Delphiuses MFstd;
function cudaMF_FFT( d_MY, d_MX:fMatrix; ht, len:UIntSize; dir:Integer );
function cudaMCF_FFT( d_MY, d_MX:cfMatrix; ht, len:UIntSize; dir:Integer );
function cudaMF_FFTtoC( d_MY:cfMatrix; d_MX:fMatrix; ht, len:UIntSize );
procedure MFcu_FFT( h_MY, h_MX:fMatrix; ht, len:UIntSize; dir:Integer );
procedure MCFcu_FFT( h_MY, h_MX:cfMatrix; ht, len:UIntSize; dir:Integer );
procedure MFcu_FFTtoC( h_MY:cfMatrix; h_MX:fMatrix; ht, len:UIntSize );
DescriptionThe Fourier transform of MX is calculated and stored in MY. The forward transform is obtained by setting dir = 1, the inverse (or backward) transform by setting dir = -1. By convention, the inverse transform involves scaling the result by the factor 1.0/(ht*len). Since it is sometimes desirable to skip this implicit scaling, MF_FFT offers the possibility to do so: specify dir = -2 in this case.
A Fast Fourier Transform algorithm is used that requires both ht and len to be powers of 2.
Complex version: Both MX and the output MY are complex matrices.
Real-to-complex version: The input matrix MX is real. The output matrix MY is complex. As this function can only perform a forward transform, no argument "dir" is needed.
Purely real version: For the forward transform, MX is a real matrix. The output MY is also defined as fMatrix, although it consists of complex numbers. The reason is that, just as in the one-dimensional case, the symmetry properties of two-dimensional FFT allow to store the result in a packed format, fitting into the same memory space as the input matrix. The order of storage in MY is derived from the ordering in the one-dimensional case, with the packing applied first to all rows, then to the columns. The resulting order is indicated in the following table. U means the uncompressed result.
U0,0.ReU0,len/2.ReU0,1.ReU0,1.Im···U0,len/2-1.ReU0,len/2-1.Im
Uht/2,0.ReUht/2,len/2.ReU1,1.ReU1,1.Im···U1,len/2-1.ReU1,len/2-1.Im
U1,0.ReU1,len/2.ReU2,1.ReU2,1.Im···U2,len/2-1.ReU2,len/2-1.Im
U1,0.ImU1,len/2.ImU3,1.ReU3,1.Im···U3,len/2-1.ReU3,len/2-1.Im
·····················
Uht/2-1,0.ReUht/2-1,len/2.Re···············
Uht/2-1,0.ImUht/2-1,len/2.ImUht-1,1.ReUht-1,1.Im···Uht-1,len/2-1.ReUht-1,len/2-1.Im
 
For inverse real-matrix FFT, the input matrix has to be of this packed-complex format, and you get a real matrix. If you prefer to get the result of forward FFT as a true complex matrix, use MF_FFTtoC.

MFb_FFT, MFb_FFTtoC and MCFb_FFT take a buffer vector Buf as an additional argument. They are slightly more efficient than the un-buffered versions. Buf must have (at least) the same size (ht*len) as MX and MY.

For historical reasons, there exist additional special versions with the prefixes MFp_,  MFs_ and MFl_. They are deprecated and may be removed in future versions.

Error handlingIf either ht or len is not a power of 2, the program is aborted with the error message "Size must be an integer power of 2".
See alsoMF_Cols_FFT,   MF_Rows_FFT,   chapter 12,   chapter 4.8 of http://www.optivec.com/vecfuncs/

MatrixLib Table of Contents  OptiVec home