FNFT
Files | Typedefs | Functions
PRIVATE: Wrapper for fast Fourier transform routines

Files

file  fnft__fft_wrapper.h
 Wraps underlying FFT library.
 
file  fnft__fft_wrapper_plan_t.h
 

Typedefs

typedef kiss_fft_cfg fnft__fft_wrapper_plan_t
 Stores information needed by fnft__fft_wrapper_execute_plan to perform a (inverse) FFT.
 

Functions

static FNFT_UINT fnft__fft_wrapper_next_fft_length (FNFT_UINT desired_length)
 Next valid number of samples for the FFT routines. More...
 
static fnft__fft_wrapper_plan_t fnft__fft_wrapper_safe_plan_init ()
 Value to initialize plan variables. More...
 
static FNFT_INT fnft__fft_wrapper_create_plan (fnft__fft_wrapper_plan_t *plan_ptr, FNFT_UINT fft_length, FNFT_COMPLEX *in, FNFT_COMPLEX *out, FNFT_INT is_inverse)
 Prepares a new (inverse) fast Fourier transform (FFT). More...
 
static FNFT_INT fnft__fft_wrapper_execute_plan (fnft__fft_wrapper_plan_t plan, FNFT_COMPLEX *in, FNFT_COMPLEX *out)
 Computes a fast Fourier transform (FFT). More...
 
static FNFT_INT fnft__fft_wrapper_destroy_plan (fnft__fft_wrapper_plan_t *plan_ptr)
 Destroys a FFT plan when it is no longer needed. More...
 
static void * fnft__fft_wrapper_malloc (FNFT_UINT size)
 Memory allocation for the FFT wrapper. More...
 
static void fnft__fft_wrapper_free (void *ptr)
 Memory deallocation for the FFT wrapper. More...
 

Detailed Description

Function Documentation

◆ fnft__fft_wrapper_create_plan()

static FNFT_INT fnft__fft_wrapper_create_plan ( fnft__fft_wrapper_plan_t plan_ptr,
FNFT_UINT  fft_length,
FNFT_COMPLEX in,
FNFT_COMPLEX out,
FNFT_INT  is_inverse 
)
inlinestatic

Prepares a new (inverse) fast Fourier transform (FFT).

Plans can be reused as long as the parameters of the FFT (fft_length and is_inverse) do not change.

Parameters
[in,out]plan_ptrPointer a fnft__fft_wrapper_plan_t object. Will be changed by the routine.
[in]fft_lengthLength of the (inverse) FFT to be computed. Must be generated using fnft__fft_wrapper_next_fft_length.
[in,out]inInput buffer with fft_length entries. Initialize after creating the plan as it might be overwritten. Create with fnft__fft_wrapper_malloc to ensure correct alignment.
[in,out]outOutput buffer with fft_length enties. Initialize after creating the plan as it might be overwritten. Create with fnft__fft_wrapper_malloc to ensure correct alignment.
[in]is_inverse-1 => forward FFT, 1 => inverse FFT. Note that the inverse FFT will not be normalized by the factor 1/fft_length.
Returns
FFT_SUCCESS or an error code.

◆ fnft__fft_wrapper_destroy_plan()

static FNFT_INT fnft__fft_wrapper_destroy_plan ( fnft__fft_wrapper_plan_t plan_ptr)
inlinestatic

Destroys a FFT plan when it is no longer needed.

Frees any memory that was allocated when the plan was created, and sets the value of the plan to fnft__fft_wrapper_safe_plan_init to avoid errors when a plan is destroyed several times.

Parameters
[in]plan_ptrPointer to a plan object created with fnft__fft_wrapper_create_plan
Returns
FFT_SUCCESS or an error code.

◆ fnft__fft_wrapper_execute_plan()

static FNFT_INT fnft__fft_wrapper_execute_plan ( fnft__fft_wrapper_plan_t  plan,
FNFT_COMPLEX in,
FNFT_COMPLEX out 
)
inlinestatic

Computes a fast Fourier transform (FFT).

Parameters
[in]planPlan object created with fnft__fft_wrapper_create_plan
[in]inInput buffer, not neccessarily the same that was used when creating the plan. The length however has to be the same. Create with fnft__fft_wrapper_malloc to ensure correct alignment.
[out]outOutput buffer, not neccessarily the same that was used when creating the plan. The length however has to be the same. Create with fnft__fft_wrapper_malloc to ensure correct alignment.
Returns
FFT_SUCCESS or an error code.

◆ fnft__fft_wrapper_free()

static void fnft__fft_wrapper_free ( void *  ptr)
inlinestatic

Memory deallocation for the FFT wrapper.

Use this routine to deallocate memory that was allocated using fnft__fft_wrapper_malloc.

Parameters
[in]ptrPointer to memory block that is to be freed (or NULL).

◆ fnft__fft_wrapper_malloc()

static void* fnft__fft_wrapper_malloc ( FNFT_UINT  size)
inlinestatic

Memory allocation for the FFT wrapper.

Use this routine to allocate memory for the input and output buffers. It ensures proper alignment.

Parameters
[in]sizeNumber of points to be allocated.
Returns
A pointer to the allocated buffer, or NULL if that failed.

◆ fnft__fft_wrapper_next_fft_length()

static FNFT_UINT fnft__fft_wrapper_next_fft_length ( FNFT_UINT  desired_length)
inlinestatic

Next valid number of samples for the FFT routines.

Returns the next larger or equal valid number of samples accepted by fnft__fft_wrapper_create_plan.

Parameters
[in]desired_lengthDesired number of samples
Returns
Actual number of samples to be used.

◆ fnft__fft_wrapper_safe_plan_init()

static fnft__fft_wrapper_plan_t fnft__fft_wrapper_safe_plan_init ( )
inlinestatic

Value to initialize plan variables.

To avoid having uninitialized plans, initialize new plans with the value returned by this function (usually, this is simply NULL).