pub trait ConvFFTExt<'a, T, S, SK, const N: usize>{
// Required methods
fn conv_fft(
&self,
kernel: impl IntoKernelWithDilation<'a, SK, N>,
conv_mode: ConvMode<N>,
padding_mode: PaddingMode<N, T>,
) -> Result<Array<T, Dim<[Ix; N]>>, Error<N>>;
fn conv_fft_with_processor(
&self,
kernel: impl IntoKernelWithDilation<'a, SK, N>,
conv_mode: ConvMode<N>,
padding_mode: PaddingMode<N, T>,
fft_processor: &mut Processor<T>,
) -> Result<Array<T, Dim<[Ix; N]>>, Error<N>>;
}
Expand description
Extends ndarray
’s ArrayBase
with FFT-accelerated convolution operations.
This trait adds the conv_fft
and conv_fft_with_processor
methods to ArrayBase
,
enabling efficient FFT-based convolutions on N-dimensional arrays.
§Type Parameters
T
: The numeric type of the array elements. Must be a floating-point type that implementsFftNum
.S
: The data storage type of the input array.SK
: The data storage type of the kernel array.
§Methods
conv_fft
: Performs an FFT-accelerated convolution with default settings.conv_fft_with_processor
: Performs an FFT-accelerated convolution using a providedProcessor
instance, allowing for reuse of FFT plans and scratch space.conv_fft_bake
: Precomputes and stores necessary data for performing repeated convolutions in the form ofBaked
.conv_fft_with_baked
: Performs a convolution with the providedBaked
data.
§Example
use ndarray::prelude::*;
use ndarray_conv::{ConvFFTExt, ConvMode, PaddingMode};
let arr = array![[1., 2.], [3., 4.]];
let kernel = array![[1., 0.], [0., 1.]];
let result = arr.conv_fft(&kernel, ConvMode::Same, PaddingMode::Zeros).unwrap();
§Notes
FFT-based convolutions are generally faster for larger kernels but may have higher overhead for smaller kernels.
Required Methods§
fn conv_fft( &self, kernel: impl IntoKernelWithDilation<'a, SK, N>, conv_mode: ConvMode<N>, padding_mode: PaddingMode<N, T>, ) -> Result<Array<T, Dim<[Ix; N]>>, Error<N>>
fn conv_fft_with_processor( &self, kernel: impl IntoKernelWithDilation<'a, SK, N>, conv_mode: ConvMode<N>, padding_mode: PaddingMode<N, T>, fft_processor: &mut Processor<T>, ) -> Result<Array<T, Dim<[Ix; N]>>, Error<N>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.