GCpp general purpose C++ library  version 1.0
GFFTDianelsonLanczos.cpp File Reference

Functions

bool GFFTCheckDim (u_int n)
 
u_int GFFTGetPower2Dim (u_int n)
 
int GFFTBaseComplex (double data[], u_int n, bool inv)
 
int GFFTComplex (double f_in[], double f_out[], u_int n, bool inv)
 
int GFFTReal2 (double f_in1[], double f_in2[], double f_out1[], double f_out2[], u_int n, bool inv)
 
int GFFTBaseReal (double data[], u_int n, bool inv)
 
int GFFTReal (double f_in[], double f_out[], u_int n, bool inv)
 

Detailed Description

Source file for the Fast Fourier Transform (FFT) functions using the Danielson-Lanczos algorithm (see Danielson-Lanczos algorithm for FFT).

Function Documentation

int GFFTBaseComplex ( double  data[],
u_int  n,
bool  inv 
)

Function implementing the Danielson-Lanczos algorithm for the FFT of a complex numbers array. The function returns 0 (no error check!). For n complex numbers, the array has length 2*n, in the following order: Re[0], Im[0], Re[1], Im[1], ... Re[n-1], Im[n-1]. The size of the data array must be at least 2*n.

Warning: the function works for a dimension that is a power of 2; this is not checked.

Parameters
datainput sample and transform result as output
nnumber of complex values
invtransformation type: false for FFT, true for inverse FFT

References FFT_2PI, and SWAP_DOUBLE.

Referenced by GFFTBaseReal(), GFFTComplex(), and GFFTReal2().

int GFFTBaseReal ( double  data[],
u_int  n,
bool  inv 
)

Function implementing the Danielson-Lanczos algorithm for the FFT of a real numbers array. The function returns 0 (no error check!).

For the FFT, the f_in array contains the real data array as input (n real values), and the f_out array receives de complex Fourier transform as output (n/2 complex values). For the inverse FFT, the f_in array contains the complex Fourier transform as input, and the f_out array receives the real samples as output.

The FFT array (complex) has length n, in the following order: Re[0], Im[0], Re[1], Im[1], ... Re[n/2-1], Im[n/2-1]. Since the sampled function is real, the transform terms 0 and n/2 are pure reals (no imaginary part), and Im[0] contains Re[n/2].

Warning: the function works for a dimension that is a power of 2; this is not checked.

Parameters
datainput sample and transform result as output
nnumber of real values
invtransformation type: false for FFT, true for inverse FFT

References FFT_PI, and GFFTBaseComplex().

Referenced by GFFTReal().

bool GFFTCheckDim ( u_int  n)

Function that recursively tests the input number to check whether it is a power of 2. This function is used to check the dimension of the arrays for the FFT functions.

Parameters
ninput number

References GFFTCheckDim().

Referenced by GFFTCheckDim(), GFFTComplex(), GFFTReal(), GFFTReal2(), and GBaseSampleFFT::InitData().

int GFFTComplex ( double  f_in[],
double  f_out[],
u_int  n,
bool  inv 
)

FFT for a complex sampling of n (being a power of 2) complex values. For n complex numbers, the arrays have length 2*n, in the following order: Re[0], Im[0], Re[1], Im[1], ... Re[n-1], Im[n-1]. The function returns 0 if no error occured.

Parameters
f_ininput samples
f_outtransform result
nsample size (number of complex values)
invtransformation type: false for FFT, true for inverse FFT

References GFFT_DIM_ERROR, GFFTBaseComplex(), and GFFTCheckDim().

u_int GFFTGetPower2Dim ( u_int  n)

Return the integer value larger or equal to n that is a power of 2.

Parameters
ninitial dimension (must be at least 2)

Referenced by GBaseSampleFFT::InitData(), and GBaseSampleFFT::ResizeData().

int GFFTReal ( double  f_in[],
double  f_out[],
u_int  n,
bool  inv 
)

FFT for a sampled real function.

For the FFT, the f_in array contains the real data array as input (n real values), and the f_out array receives de complex Fourier transform as output (n/2 complex values). For the inverse FFT, the f_in array contains the complex Fourier transform as input, and the f_out array receives the real samples as output.

The FFT array (complex) has length n, in the following order: Re[0], Im[0], Re[1], Im[1], ... Re[n/2-1], Im[n/2-1]. Since the sampled function is real, the transform terms 0 and n/2 are pure reals (no imaginary part), and Im[0] contains Re[n/2].

Parameters
f_ininput samples
f_outtransform result
nsample size (number of real values)
invtransformation type: false for FFT, true for inverse FFT

References GFFT_DIM_ERROR, GFFTBaseReal(), and GFFTCheckDim().

Referenced by GRealSampleFFT::ComputeFunctionData(), and GRealSampleFFT::ComputeTransformData().

int GFFTReal2 ( double  f_in1[],
double  f_in2[],
double  f_out1[],
double  f_out2[],
u_int  n,
bool  inv 
)

Simultaneous FFT for 2 real samples of n (being a power of 2) real values. The function uses the complex samples FFT algorithm. The function returns 0 if no error occured. The input and output arrays have a dimension n.

For the FFT, the f_in arrays contain the real data array as input (n real values), and the f_out arrays receive de complex Fourier transform as output (n/2 complex values). For the inverse FFT, the f_in arrays contain the complex Fourier transform as input, and the f_out arrays receive the real samples as output.

The FFT arrays contains n/2 complex values, in the following order: Re[0], Im[0], Re[1], Im[1], ... Re[n/2-1], Im[n/2-1]. Since the sampled functions are real, the transform terms 0 and n/2 are pure reals (no imaginary part), and Im[0] contains Re[n/2].

Parameters
f_in1function 1 samples (input)
f_in2function 2 samples (input)
f_out1transform 1 function result (output)
f_out2transform 2 function result (output)
nsample size (number of complex values)
invtransformation type: false for FFT, true for inverse FFT

References GFFT_DIM_ERROR, GFFTBaseComplex(), and GFFTCheckDim().