FFT-1D (Fast Fourier Transform, One-Dimensional)
File:
/src/signal.hppLines 659–681 /**
* @brief Performs a 1D N-point FFT on a given signal. Note: N must to be a power of two.
*
* We map N-point FFT using the Cooley–Tukey FFT algorithm. Similar to the explanation found here:
* https://www.cs.cmu.edu/afs/andrew/scs/cs/15-463/2001/pub/www/notes/fourier/fourier.pdf.
*
* For an inverse FFT, the imaginary part is negated before and after the forward FFT, also before the output, both
* are divided by `numInputPoints`.
*
* Reference: https://www.dsprelated.com/showarticle/800.php, method 4
*
* @tparam complexInput Set to `True` if the input is complex, `False` if input is real.
* @tparam DdrInOutSignalTensorShape DDR input tensor. Expected to be of the form `<1, complexCount, 1, inputPoints>`. `ComplexCount` = 1 if only real or 2 if complex.
* @tparam qvarElemType Default is `DdrInOutSignalTensorShape::elemType` .
* @param ddrIn OCM allocator to be used locally in FFT to allocate ocm memory space.
* @param ddrOut OCM allocator to be used locally in FFT to allocate ocm memory space.
* @param ocmMemAlloc OCM allocator to be used locally in FFT to allocate ocm memory space.
*/
// clang-format on
template <bool complexInput = true,
typename DdrInOutSignalTensorShape,
typename qvarElemType = typename DdrInOutSignalTensorShape::elemType>
void fft1d(DdrInOutSignalTensorShape& ddrIn, DdrInOutSignalTensorShape& ddrOut, MemAllocator& ocmMemAlloc) {
File:
/src/signal.hppLines 802–814 /**
* @brief Computes FFT with pre-computed weights for real-valued, multi-channel input.
*
* @tparam OcmInputShape Expected to be of the form `<1, 1, numChannels, inputPoints>` .
* @tparam OcmFftShape Expected to be of the form `<1, 2, numChannels, numRfftFrequencies>` .
* @tparam qvarElemType Default is `OcmInputShape::elemType` .
* @param ocmMem OCM allocator used internally for RAU.
* @param ocmIn Input 1D signal stored in OCM.
* @param ocmOut The real-FFT output for all channels.
*/
// clang-format on
template <typename OcmInputShape, typename OcmFftShape, typename qvarElemType = typename OcmInputShape::elemType>
void rfft1d(MemAllocator& ocmMem, OcmInputShape& ocmIn, OcmFftShape& ocmOut) {
FFT-2D (Fast Fourier Transform, Two-Dimensional)
File:
/src/signal.hppLines 934–956 /**
* @brief Performs a 2D N-point FFT on a given signal.
* @ingroup qmath_ops
*
* @tparam DdrInOutSignalTensorShape Input/output tensor shape. Expected form `<1, 2, NR, NC>` —
* complex (2 channels), and `NR`, `NC` independent powers of 2.
* `NR == NC` is the common square case; non-square shapes
* (e.g. radar range × Doppler) are also supported.
* @tparam scaling Output scaling policy. `FftScaling::Unscaled` (default) returns the literal
* forward DFT `out[k] = sum_n x[n] * exp(-j 2 pi k n / N)`; `FftScaling::BlockFp`
* right-shifts the data path by 1 bit per butterfly stage so the output equals
* `DFT2(x) / (NR*NC)` exactly, reclaiming the full input Q-format dynamic range.
* See `FftScaling` for details.
* @tparam qvarElemType Default is `DdrInOutSignalTensorShape::elemType` .
* @param ddrIn Input 2D signal stored in external memory.
* @param ddrOut Output tensor where calculated 2D FFT will be stored.
* @param ocmMemAlloc OCM allocator to be used locally in FFT to allocate OCM space.
*/
// clang-format on
template <typename DdrInOutSignalTensorShape,
FftScaling scaling = FftScaling::Unscaled,
typename qvarElemType = typename DdrInOutSignalTensorShape::elemType>
void fft2d(DdrInOutSignalTensorShape& ddrIn, DdrInOutSignalTensorShape& ddrOut, MemAllocator& ocmMemAlloc) {