numerics
Loading...
Searching...
No Matches
fft.hpp File Reference

FFT interface with backend dispatch. More...

#include "core/types.hpp"
#include "core/vector.hpp"

Go to the source code of this file.

Classes

class  num::spectral::FFTPlan
 Precomputed plan for repeated complex transforms of a fixed size. More...
 

Namespaces

namespace  num
 
namespace  num::spectral
 

Enumerations

enum class  num::spectral::FFTBackend { num::spectral::seq , num::spectral::simd , num::spectral::stdsimd , num::spectral::fftw }
 Selects which backend handles an FFT operation. More...
 

Functions

void num::spectral::fft (const CVector &in, CVector &out, FFTBackend b=default_fft_backend)
 Forward complex DFT. out must be pre-allocated to in.size().
 
void num::spectral::ifft (const CVector &in, CVector &out, FFTBackend b=default_fft_backend)
 Inverse complex DFT (unnormalised: result = n * true_inverse).
 
void num::spectral::rfft (const Vector &in, CVector &out, FFTBackend b=default_fft_backend)
 Real-to-complex forward DFT. out must be pre-allocated to n/2+1.
 
void num::spectral::irfft (const CVector &in, int n, Vector &out, FFTBackend b=default_fft_backend)
 Complex-to-real inverse DFT (unnormalised).
 

Variables

constexpr FFTBackend num::spectral::seq = FFTBackend::seq
 
constexpr FFTBackend num::spectral::fftw = FFTBackend::fftw
 
constexpr FFTBackend num::spectral::fft_simd = FFTBackend::simd
 
constexpr FFTBackend num::spectral::fft_stdsimd = FFTBackend::stdsimd
 
constexpr bool num::spectral::has_fftw
 True when FFTW3 was found at configure time.
 
constexpr bool num::spectral::has_fft_simd
 True when handwritten AVX2 or NEON backend is available.
 
constexpr bool num::spectral::has_fft_stdsimd
 True when std::experimental::simd is available.
 
constexpr FFTBackend num::spectral::default_fft_backend
 Automatically selected at configure time: fftw > simd > seq.
 

Detailed Description

FFT interface with backend dispatch.

Each module defines its own backend enum for the choices relevant to it. This enum covers spectral transforms; linalg uses num::Backend in core/policy.hpp.

Backends: FFTBackend::seq – native Cooley-Tukey radix-2 DIT; always available. Input length must be a power of two. FFTBackend::fftw – FFTW3 (AVX / NEON optimised); requires NUMERICS_HAS_FFTW. Falls back to FFTBackend::seq automatically if FFTW3 is absent.

Conventions (both backends): Forward DFT: X[k] = sum_{j=0}^{n-1} x[j] * exp(-2*pi*i*j*k/n) Inverse DFT: unnormalised (FFTW convention). Divide by n to recover x. rfft output: n/2+1 complex bins (Hermitian symmetry of real input).

Definition in file fft.hpp.