Skip to main content

convolve

Function convolve 

Source
pub fn convolve<T>(
    a: &Array<T, Ix1>,
    v: &Array<T, Ix1>,
    mode: ConvolveMode,
) -> Result<Array<T, Ix1>, FerrayError>
where T: Element + Add<Output = T> + Mul<Output = T> + Copy,
Expand description

Discrete, linear convolution of two 1-D arrays.

Computes convolve(a, v, mode) following NumPy semantics — direct O(n·m) algorithm, matching numpy.convolve. For large floating-point inputs prefer [fftconvolve] (behind the fft-convolve feature), which is O((n+m) · log(n+m)) via FFT.

The inner loop is restructured to iterate over output positions rather than input pairs (#89). The previous form full[i+j] += a[i] * v[j] had a strided write pattern that confused auto-vectorisation; iterating over k = i+j and accumulating a dot product Σ a[i] * v[k-i] gives the auto- vectoriser a clean inner loop with linear writes.