Module dsp::convolution
Convolution
Linear (non-circular) convolution: y[n] = sum_k x[k] * h[n-k], output length len_x + len_h - 1. Two implementations with the same output for the same input, trading off differently:
conv_direct / fconv_direct — O(len_x * len_h), no allocation, exact
(fconv_direct: exact up to Q8.24 rounding). Best for short filters
(e.g. convolving with a small FIR kernel).
conv_fft — O(n log n) via fft.h, allocates a scratch buffer sized to
the next power of two >= output length. Best for long inputs/long
kernels, where direct convolution's O(len_x*len_h) cost dominates.
Functions
| conv_direct | out must have space for (len_x + len_h - 1) samples. |
| fconv_direct | |
| conv_fft | FFT-accelerated linear convolution — same output as conv_direct (up to floating-point rounding), computed via zero-padded forward FFTs, pointwise complex multiply, and one inverse FFT. out must have space for (len_x + len_h - 1) samples. |
| conv_direct_f32 | Single precision: conv_direct / conv_fft on floats, same contracts. |
| conv_fft_f32 |