Trait ConvFFTExt

Source
pub trait ConvFFTExt<'a, T, S, SK, const N: usize>
where T: FftNum + NumAssign, S: RawData, SK: RawData,
{ // 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 implements FftNum.
  • 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 provided Processor 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 of Baked.
  • conv_fft_with_baked: Performs a convolution with the provided Baked 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§

Source

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>>

Source

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.

Implementations on Foreign Types§

Source§

impl<'a, T, S, SK, const N: usize> ConvFFTExt<'a, T, S, SK, N> for ArrayBase<S, Dim<[Ix; N]>>
where T: NumAssign + FftNum, S: Data<Elem = T> + 'a, SK: Data<Elem = T> + 'a, [Ix; N]: IntoDimension<Dim = Dim<[Ix; N]>>, SliceInfo<[SliceInfoElem; N], Dim<[Ix; N]>, Dim<[Ix; N]>>: SliceArg<Dim<[Ix; N]>, OutDim = Dim<[Ix; N]>>, Dim<[Ix; N]>: RemoveAxis,

Source§

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>>

Source§

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>>

Implementors§