Project Ne10
An open, optimized software library for the ARM architecture.
Functions | Variables
Real-to-Complex FFT (Floating & Fixed Point)

Functions

ne10_fft_r2c_cfg_float32_t ne10_fft_alloc_r2c_float32 (ne10_int32_t nfft)
 Creates a configuration structure for variants of ne10_fft_r2c_1d_float32 and ne10_fft_c2r_1d_float32. More...
 
void ne10_fft_r2c_1d_float32_c (ne10_fft_cpx_float32_t *fout, ne10_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
 Specific implementation of ne10_fft_r2c_1d_float32 using plain C. More...
 
void ne10_fft_r2c_1d_float32_neon (ne10_fft_cpx_float32_t *fout, ne10_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
 Specific implementation of ne10_fft_r2c_1d_float32 using NEON SIMD capabilities. More...
 
void ne10_fft_c2r_1d_float32_c (ne10_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
 Specific implementation of ne10_fft_c2r_1d_float32 using plain C. More...
 
void ne10_fft_c2r_1d_float32_neon (ne10_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
 Specific implementation of ne10_fft_c2r_1d_float32 using NEON SIMD capabilities. More...
 
void ne10_fft_destroy_r2c_float32 (ne10_fft_r2c_cfg_float32_t cfg)
 Destroys the configuration structure allocated by ne10_fft_alloc_r2c_float32 (frees memory, etc.) More...
 
ne10_fft_r2c_cfg_int32_t ne10_fft_alloc_r2c_int32 (ne10_int32_t nfft)
 Creates a configuration structure for variants of ne10_fft_r2c_1d_int32 and ne10_fft_c2r_1d_int32. More...
 
void ne10_fft_r2c_1d_int32_c (ne10_fft_cpx_int32_t *fout, ne10_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_r2c_1d_int32 using plain C. More...
 
void ne10_fft_r2c_1d_int32_neon (ne10_fft_cpx_int32_t *fout, ne10_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_r2c_1d_int32 using NEON SIMD capabilities. More...
 
void ne10_fft_c2r_1d_int32_c (ne10_int32_t *fout, ne10_fft_cpx_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_c2r_1d_int32 using plain C. More...
 
void ne10_fft_c2r_1d_int32_neon (ne10_int32_t *fout, ne10_fft_cpx_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_c2r_1d_int32 using NEON SIMD capabilities. More...
 
void ne10_fft_destroy_r2c_int32 (ne10_fft_r2c_cfg_int32_t cfg)
 Destroys the configuration structure allocated by ne10_fft_alloc_r2c_int32 (frees memory, etc.) More...
 
ne10_fft_r2c_cfg_int16_t ne10_fft_alloc_r2c_int16 (ne10_int32_t nfft)
 Creates a configuration structure for variants of ne10_fft_r2c_1d_int16 and ne10_fft_c2r_1d_int16. More...
 
void ne10_fft_r2c_1d_int16_c (ne10_fft_cpx_int16_t *fout, ne10_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_r2c_1d_int16 using plain C. More...
 
void ne10_fft_r2c_1d_int16_neon (ne10_fft_cpx_int16_t *fout, ne10_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_r2c_1d_int16 using NEON SIMD capabilities. More...
 
void ne10_fft_c2r_1d_int16_c (ne10_int16_t *fout, ne10_fft_cpx_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_c2r_1d_int16 using plain C. More...
 
void ne10_fft_c2r_1d_int16_neon (ne10_int16_t *fout, ne10_fft_cpx_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)
 Specific implementation of ne10_fft_c2r_1d_int16 using NEON SIMD capabilities. More...
 
void ne10_fft_destroy_r2c_int16 (ne10_fft_r2c_cfg_int16_t cfg)
 Destroys the configuration structure allocated by ne10_fft_alloc_r2c_int16 (frees memory, etc.) More...
 

Variables

void(* ne10_fft_r2c_1d_float32 )(ne10_fft_cpx_float32_t *fout, ne10_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
 Mixed radix-2/4 real-to-complex FFT of single precision floating point data. More...
 
void(* ne10_fft_c2r_1d_float32 )(ne10_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
 Mixed radix-2/4 complex-to-real IFFT of single precision floating point data. More...
 
void(* ne10_fft_r2c_1d_int32 )(ne10_fft_cpx_int32_t *fout, ne10_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)
 Mixed radix-2/4 real-to-complex FFT of 32-bit fixed point Q31 data. More...
 
void(* ne10_fft_c2r_1d_int32 )(ne10_int32_t *fout, ne10_fft_cpx_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)
 Mixed radix-2/4 complex-to-real IFFT of 32-bit fixed point Q31 data. More...
 
void(* ne10_fft_r2c_1d_int16 )(ne10_fft_cpx_int16_t *fout, ne10_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)
 Mixed radix-2/4 real-to-complex FFT of 16-bit fixed point Q15 data. More...
 
void(* ne10_fft_c2r_1d_int16 )(ne10_int16_t *fout, ne10_fft_cpx_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)
 Mixed radix-2/4 complex-to-real IFFT of 16-bit fixed point Q15 data. More...
 

Detailed Description

In practical applications, it is often the case that full complex-to-complex FFT operations are unnecessary; many applications deal exclusively with real signals. For this reason, Ne10 provides real-to-complex and complex-to-real 1D FFT/IFFT operations.
As with their complex-to-complex counterparts, in the absence of scaling controls within the function signature these functions scale the data by $1/N$ in the inverse transformation only.
Three variants of these FFT/IFFT functions are provided, operating on FP32, Q31, and Q15 data types. Each has a plain C implementation, a NEON implementation, and a function pointer to select between these at runtime (see ne10_init). More detailed descriptions of these functions can be found alongside the relevant function pointers:
Supported lengths
These functions support input sizes of the form 2N (for integers N > 0).
Memory layout
These functions operate out-of-place, using different buffers for their input and output. An additional temporary buffer is also used internally to store intermediate results. The input and output buffers should be allocated by the user, while the temporary buffer is reserved during allocation of a "configuration structure" (for instance, via ne10_fft_alloc_r2c_float32).
Buffers of complex elements interleave the real and imaginary parts of each element, storing these contiguously, while buffers of real elements simply hold values contiguously in memory as simple C arrays. As real-to-complex Fourier transforms display conjugate symmetry, outputs from the forwards transform will be only (fftSize / 2) + 1 complex elements long. Similarly, inputs to the inverse transform need only be this long.
Real-to-Complex (R2C) FFT:
    Input:  { Re[0], Re[1], Re[2], Re[3], Re[4], Re[5], ..., Re[fftSize - 4], Re[fftSize - 3], Re[fftSize - 2], Re[fftSize - 1] }
    Output: { Re[0], Im[0], Re[1], Im[1], Re[2], Im[2], ..., Re[(fftSize / 2) - 1], Im[(fftSize / 2) - 1], Re[(fftSize / 2)], Im[(fftSize / 2)] }
Complex-to-Real (C2R) IFFT:
    Input:  { Re[0], Im[0], Re[1], Im[1], Re[2], Im[2], ..., Re[(fftSize / 2) - 1], Im[(fftSize / 2) - 1], Re[(fftSize / 2)], Im[(fftSize / 2)] }
    Output: { Re[0], Re[1], Re[2], Re[3], Re[4], Re[5], ..., Re[fftSize - 4], Re[fftSize - 3], Re[fftSize - 2], Re[fftSize - 1] }
Example usage
A single precision floating point FFT/IFFT example code snippet follows.
#include "NE10.h"
...
{
ne10_int32_t fftSize = 1024;
ne10_fft_r2c_cfg_float32_t cfg = ne10_fft_alloc_r2c_float32_neon(fftSize); // Allocate a configuration structure for R2C/C2R FP32 NEON FFTs of size fftSize
ne10_float32_t *in = malloc(fftSize * sizeof(ne10_float32_t)); // Allocate an input array of samples
ne10_fft_cpx_float32_t *out = malloc(fftSize * sizeof(ne10_fft_cpx_float32_t)); // Allocate an (oversized) output array of samples
...
// FFT
ne10_fft_r2c_1d_float32_neon(out, in, cfg); // Call the FP32 R2C NEON implementation directly
...
// IFFT
ne10_fft_c2r_1d_float32_neon(in, out, cfg); // Call the FP32 C2R NEON implementation directly (reusing the configuration structure!)
...
NE10_FREE(out); // Free the allocated input array
NE10_FREE(in); // Free the allocated output array
ne10_fft_destroy_r2c_float32(cfg); // Free the allocated configuration structure
}
The ne10_fft_r2c_cfg_float32_t variable cfg is a pointer to a configuration structure. For different inputs of the same size, the same configuration structure can (and should, where possible) be reused.
The contents of these configuration structures include:
  • cfg->twiddles: a pointer to a table of "twiddle factors" that are used in computing the FFT/IFFT
  • cfg->super_twiddles: a pointer to a table of twiddle factors used in splitting complex and real components
  • cfg->factors: a buffer of "factors", which suggests to the core algorithm how the input can be broken down into smaller calculations
  • cfg->buffer: a pointer to a temporary buffer used internally in calculations that is allocated when the configuration structure is set up

Function Documentation

ne10_fft_r2c_cfg_float32_t ne10_fft_alloc_r2c_float32 ( ne10_int32_t  nfft)

Creates a configuration structure for variants of ne10_fft_r2c_1d_float32 and ne10_fft_c2r_1d_float32.

Parameters
[in]nfftinput length
Return values
stpointer to an FFT configuration structure (allocated with malloc), or NULL to indicate an error

Allocates and initialises an ne10_fft_r2c_cfg_float32_t configuration structure for the FP32 real-to-complex and complex-to-real FFT/IFFT. As part of this, it reserves a buffer used internally by the FFT algorithm, factors the length of the FFT into simpler chunks, and generates a "twiddle table" of coefficients used in the FFT "butterfly" calculations.

To free the returned structure, call ne10_fft_destroy_r2c_float32.

Examples:
NE10_sample_real_fft.c.

Definition at line 943 of file NE10_fft_float32.c.

ne10_fft_r2c_cfg_int16_t ne10_fft_alloc_r2c_int16 ( ne10_int32_t  nfft)

Creates a configuration structure for variants of ne10_fft_r2c_1d_int16 and ne10_fft_c2r_1d_int16.

Parameters
[in]nfftinput length
Return values
stpointer to an FFT configuration structure (allocated with malloc), or NULL to indicate an error

Allocates and initialises an ne10_fft_r2c_cfg_int16_t configuration structure for the INT16 real-to-complex and complex-to-real FFT/IFFT. As part of this, it reserves a buffer used internally by the FFT algorithm, factors the length of the FFT into simpler chunks, and generates a "twiddle table" of coefficients used in the FFT "butterfly" calculations.

To free the returned structure, call ne10_fft_destroy_r2c_int16.

Definition at line 1163 of file NE10_fft_int16.c.

ne10_fft_r2c_cfg_int32_t ne10_fft_alloc_r2c_int32 ( ne10_int32_t  nfft)

Creates a configuration structure for variants of ne10_fft_r2c_1d_int32 and ne10_fft_c2r_1d_int32.

Parameters
[in]nfftinput length
Return values
stpointer to an FFT configuration structure (allocated with malloc), or NULL to indicate an error

Allocates and initialises an ne10_fft_r2c_cfg_int32_t configuration structure for the INT32 real-to-complex and complex-to-real FFT/IFFT. As part of this, it reserves a buffer used internally by the FFT algorithm, factors the length of the FFT into simpler chunks, and generates a "twiddle table" of coefficients used in the FFT "butterfly" calculations.

To free the returned structure, call ne10_fft_destroy_r2c_int32.

Definition at line 1157 of file NE10_fft_int32.c.

void ne10_fft_c2r_1d_float32_c ( ne10_float32_t fout,
ne10_fft_cpx_float32_t fin,
ne10_fft_r2c_cfg_float32_t  cfg 
)

Specific implementation of ne10_fft_c2r_1d_float32 using plain C.

Definition at line 1036 of file NE10_fft_float32.c.

void ne10_fft_c2r_1d_float32_neon ( ne10_float32_t fout,
ne10_fft_cpx_float32_t fin,
ne10_fft_r2c_cfg_float32_t  cfg 
)

Specific implementation of ne10_fft_c2r_1d_float32 using NEON SIMD capabilities.

Definition at line 766 of file NE10_fft_float32.neon.c.

void ne10_fft_c2r_1d_int16_c ( ne10_int16_t fout,
ne10_fft_cpx_int16_t fin,
ne10_fft_r2c_cfg_int16_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_c2r_1d_int16 using plain C.

Definition at line 1257 of file NE10_fft_int16.c.

void ne10_fft_c2r_1d_int16_neon ( ne10_int16_t fout,
ne10_fft_cpx_int16_t fin,
ne10_fft_r2c_cfg_int16_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_c2r_1d_int16 using NEON SIMD capabilities.

Definition at line 899 of file NE10_fft_int16.neon.c.

void ne10_fft_c2r_1d_int32_c ( ne10_int32_t fout,
ne10_fft_cpx_int32_t fin,
ne10_fft_r2c_cfg_int32_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_c2r_1d_int32 using plain C.

Definition at line 1251 of file NE10_fft_int32.c.

void ne10_fft_c2r_1d_int32_neon ( ne10_int32_t fout,
ne10_fft_cpx_int32_t fin,
ne10_fft_r2c_cfg_int32_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_c2r_1d_int32 using NEON SIMD capabilities.

Definition at line 1347 of file NE10_fft_int32.neon.c.

void ne10_fft_destroy_r2c_float32 ( ne10_fft_r2c_cfg_float32_t  cfg)

Destroys the configuration structure allocated by ne10_fft_alloc_r2c_float32 (frees memory, etc.)

Parameters
[in]cfgpointer to the FFT configuration structure
Examples:
NE10_sample_real_fft.c.

Definition at line 593 of file NE10_fft.c.

void ne10_fft_destroy_r2c_int16 ( ne10_fft_r2c_cfg_int16_t  cfg)

Destroys the configuration structure allocated by ne10_fft_alloc_r2c_int16 (frees memory, etc.)

Parameters
[in]cfgpointer to the FFT configuration structure

Definition at line 613 of file NE10_fft.c.

void ne10_fft_destroy_r2c_int32 ( ne10_fft_r2c_cfg_int32_t  cfg)

Destroys the configuration structure allocated by ne10_fft_alloc_r2c_int32 (frees memory, etc.)

Parameters
[in]cfgpointer to the FFT configuration structure

Definition at line 603 of file NE10_fft.c.

void ne10_fft_r2c_1d_float32_c ( ne10_fft_cpx_float32_t fout,
ne10_float32_t fin,
ne10_fft_r2c_cfg_float32_t  cfg 
)

Specific implementation of ne10_fft_r2c_1d_float32 using plain C.

Definition at line 1022 of file NE10_fft_float32.c.

void ne10_fft_r2c_1d_float32_neon ( ne10_fft_cpx_float32_t fout,
ne10_float32_t fin,
ne10_fft_r2c_cfg_float32_t  cfg 
)

Specific implementation of ne10_fft_r2c_1d_float32 using NEON SIMD capabilities.

Definition at line 745 of file NE10_fft_float32.neon.c.

void ne10_fft_r2c_1d_int16_c ( ne10_fft_cpx_int16_t fout,
ne10_int16_t fin,
ne10_fft_r2c_cfg_int16_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_r2c_1d_int16 using plain C.

Definition at line 1242 of file NE10_fft_int16.c.

void ne10_fft_r2c_1d_int16_neon ( ne10_fft_cpx_int16_t fout,
ne10_int16_t fin,
ne10_fft_r2c_cfg_int16_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_r2c_1d_int16 using NEON SIMD capabilities.

Definition at line 877 of file NE10_fft_int16.neon.c.

void ne10_fft_r2c_1d_int32_c ( ne10_fft_cpx_int32_t fout,
ne10_int32_t fin,
ne10_fft_r2c_cfg_int32_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_r2c_1d_int32 using plain C.

Definition at line 1236 of file NE10_fft_int32.c.

void ne10_fft_r2c_1d_int32_neon ( ne10_fft_cpx_int32_t fout,
ne10_int32_t fin,
ne10_fft_r2c_cfg_int32_t  cfg,
ne10_int32_t  scaled_flag 
)

Specific implementation of ne10_fft_r2c_1d_int32 using NEON SIMD capabilities.

Definition at line 1325 of file NE10_fft_int32.neon.c.

Variable Documentation

void(* ne10_fft_c2r_1d_float32) (ne10_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)

Mixed radix-2/4 complex-to-real IFFT of single precision floating point data.

Parameters
[out]*foutpointer to the output buffer
[in]*finpointer to the input buffer
[in]cfgpointer to the configuration structure (allocated via ne10_fft_alloc_r2c_float32)

The function implements a mixed radix-2/4 complex-to-real IFFT, supporting input lengths of the form 2N (N > 0). Points to ne10_fft_c2r_1d_float32_c or ne10_fft_c2r_1d_float32_neon. This is an out-of-place algorithm. For usage information, please check test/test_suite_fft_float32.c.

Definition at line 126 of file NE10_init_dsp.c.

void(* ne10_fft_c2r_1d_int16) (ne10_int16_t *fout, ne10_fft_cpx_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)

Mixed radix-2/4 complex-to-real IFFT of 16-bit fixed point Q15 data.

Parameters
[out]*foutpointer to the output buffer
[in]*finpointer to the input buffer
[in]cfgpointer to the configuration structure (allocated via ne10_fft_alloc_r2c_int16)
[in]scaled_flagscale flag (0: unscaled, 1: scaled)

The function implements a mixed radix-2/4 complex-to-real IFFT, supporting input lengths of the form 2N (N > 0). Points to ne10_fft_c2r_1d_int16_c or ne10_fft_c2r_1d_int16_neon. This is an out-of-place algorithm. For usage information, please check test/test_suite_fft_int16.c.

Definition at line 158 of file NE10_init_dsp.c.

void(* ne10_fft_c2r_1d_int32) (ne10_int32_t *fout, ne10_fft_cpx_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)

Mixed radix-2/4 complex-to-real IFFT of 32-bit fixed point Q31 data.

Parameters
[out]*foutpointer to the output buffer
[in]*finpointer to the input buffer
[in]cfgpointer to the configuration structure (allocated via ne10_fft_alloc_r2c_int32)
[in]scaled_flagscale flag (0: unscaled, 1: scaled)

The function implements a mixed radix-2/4 complex-to-real IFFT, supporting input lengths of the form 2N (N > 0). Points to ne10_fft_c2r_1d_int32_c or ne10_fft_c2r_1d_int32_neon. This is an out-of-place algorithm. For usage information, please check test/test_suite_fft_int32.c.

Definition at line 142 of file NE10_init_dsp.c.

void(* ne10_fft_r2c_1d_float32) (ne10_fft_cpx_float32_t *fout, ne10_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)

Mixed radix-2/4 real-to-complex FFT of single precision floating point data.

Parameters
[out]*foutpointer to the output buffer
[in]*finpointer to the input buffer
[in]cfgpointer to the configuration structure (allocated via ne10_fft_alloc_r2c_float32)

The function implements a mixed radix-2/4 real-to-complex FFT, supporting input lengths of the form 2N (N > 0). Points to ne10_fft_r2c_1d_float32_c or ne10_fft_r2c_1d_float32_neon. This is an out-of-place algorithm. For usage information, please check test/test_suite_fft_float32.c.

For the inverse transform (IFFT), call ne10_fft_c2r_1d_float32.

Examples:
NE10_sample_real_fft.c.

Definition at line 122 of file NE10_init_dsp.c.

void(* ne10_fft_r2c_1d_int16) (ne10_fft_cpx_int16_t *fout, ne10_int16_t *fin, ne10_fft_r2c_cfg_int16_t cfg, ne10_int32_t scaled_flag)

Mixed radix-2/4 real-to-complex FFT of 16-bit fixed point Q15 data.

Parameters
[out]*foutpointer to the output buffer
[in]*finpointer to the input buffer
[in]cfgpointer to the configuration structure (allocated via ne10_fft_alloc_r2c_int16)
[in]scaled_flagscale flag (0: unscaled, 1: scaled)

The function implements a mixed radix-2/4 real-to-complex FFT, supporting input lengths of the form 2N (N > 0). Points to ne10_fft_r2c_1d_int16_c or ne10_fft_r2c_1d_int16_neon. This is an out-of-place algorithm. For usage information, please check test/test_suite_fft_int16.c.

For the inverse transform (IFFT), call ne10_fft_c2r_1d_int16.

Definition at line 153 of file NE10_init_dsp.c.

void(* ne10_fft_r2c_1d_int32) (ne10_fft_cpx_int32_t *fout, ne10_int32_t *fin, ne10_fft_r2c_cfg_int32_t cfg, ne10_int32_t scaled_flag)

Mixed radix-2/4 real-to-complex FFT of 32-bit fixed point Q31 data.

Parameters
[out]*foutpointer to the output buffer
[in]*finpointer to the input buffer
[in]cfgpointer to the configuration structure (allocated via ne10_fft_alloc_r2c_int32)
[in]scaled_flagscale flag (0: unscaled, 1: scaled)

The function implements a mixed radix-2/4 real-to-complex FFT, supporting input lengths of the form 2N (N > 0). Points to ne10_fft_r2c_1d_int32_c or ne10_fft_r2c_1d_int32_neon. This is an out-of-place algorithm. For usage information, please check test/test_suite_fft_int32.c.

For the inverse transform (IFFT), call ne10_fft_c2r_1d_int32.

Definition at line 137 of file NE10_init_dsp.c.