Trait rustfft::Fft

source ·
pub trait Fft<T: FftNum>: Length + Direction + Sync + Send {
    // Required methods
    fn process_with_scratch(
        &self,
        buffer: &mut [Complex<T>],
        scratch: &mut [Complex<T>]
    );
    fn process_outofplace_with_scratch(
        &self,
        input: &mut [Complex<T>],
        output: &mut [Complex<T>],
        scratch: &mut [Complex<T>]
    );
    fn get_inplace_scratch_len(&self) -> usize;
    fn get_outofplace_scratch_len(&self) -> usize;

    // Provided method
    fn process(&self, buffer: &mut [Complex<T>]) { ... }
}
Expand description

Trait for algorithms that compute FFTs.

This trait has a few methods for computing FFTs. Its most conveinent method is process(slice). It takes in a slice of Complex<T> and computes a FFT on that slice, in-place. It may copy the data over to internal scratch buffers if that speeds up the computation, but the output will always end up in the same slice as the input.

Required Methods§

source

fn process_with_scratch( &self, buffer: &mut [Complex<T>], scratch: &mut [Complex<T>] )

Divides buffer into chunks of size self.len(), and computes a FFT on each chunk.

Uses the scratch buffer as scratch space, so the contents of scratch should be considered garbage after calling.

§Panics

This method panics if:

  • buffer.len() % self.len() > 0
  • buffer.len() < self.len()
  • scratch.len() < self.get_inplace_scratch_len()
source

fn process_outofplace_with_scratch( &self, input: &mut [Complex<T>], output: &mut [Complex<T>], scratch: &mut [Complex<T>] )

Divides input and output into chunks of size self.len(), and computes a FFT on each chunk.

This method uses both the input buffer and scratch buffer as scratch space, so the contents of both should be considered garbage after calling.

This is a more niche way of computing a FFT. It’s useful to avoid a copy_from_slice() if you need the output in a different buffer than the input for some reason. This happens frequently in RustFFT internals, but is probably less common among RustFFT users.

For many FFT sizes, self.get_outofplace_scratch_len() returns 0

§Panics

This method panics if:

  • output.len() != input.len()
  • input.len() % self.len() > 0
  • input.len() < self.len()
  • scratch.len() < self.get_outofplace_scratch_len()
source

fn get_inplace_scratch_len(&self) -> usize

Returns the size of the scratch buffer required by process_with_scratch

For most FFT sizes, this method will return self.len(). For a few small sizes it will return 0, and for some special FFT sizes (Sizes that require the use of Bluestein’s Algorithm), this may return a scratch size larger than self.len(). The returned value may change from one version of RustFFT to the next.

source

fn get_outofplace_scratch_len(&self) -> usize

Returns the size of the scratch buffer required by process_outofplace_with_scratch

For most FFT sizes, this method will return 0. For some special FFT sizes (Sizes that require the use of Bluestein’s Algorithm), this may return a scratch size larger than self.len(). The returned value may change from one version of RustFFT to the next.

Provided Methods§

source

fn process(&self, buffer: &mut [Complex<T>])

Computes a FFT in-place.

Convenience method that allocates a Vec with the required scratch space and calls self.process_with_scratch. If you want to re-use that allocation across multiple FFT computations, consider calling process_with_scratch instead.

§Panics

This method panics if:

  • buffer.len() % self.len() > 0
  • buffer.len() < self.len()

Implementors§

source§

impl<T: FftNum> Fft<T> for Butterfly1<T>

source§

impl<T: FftNum> Fft<T> for Butterfly2<T>

source§

impl<T: FftNum> Fft<T> for Butterfly3<T>

source§

impl<T: FftNum> Fft<T> for Butterfly4<T>

source§

impl<T: FftNum> Fft<T> for Butterfly5<T>

source§

impl<T: FftNum> Fft<T> for Butterfly6<T>

source§

impl<T: FftNum> Fft<T> for Butterfly7<T>

source§

impl<T: FftNum> Fft<T> for Butterfly8<T>

source§

impl<T: FftNum> Fft<T> for Butterfly9<T>

source§

impl<T: FftNum> Fft<T> for Butterfly11<T>

source§

impl<T: FftNum> Fft<T> for Butterfly13<T>

source§

impl<T: FftNum> Fft<T> for Butterfly16<T>

source§

impl<T: FftNum> Fft<T> for Butterfly17<T>

source§

impl<T: FftNum> Fft<T> for Butterfly19<T>

source§

impl<T: FftNum> Fft<T> for Butterfly23<T>

source§

impl<T: FftNum> Fft<T> for Butterfly27<T>

source§

impl<T: FftNum> Fft<T> for Butterfly29<T>

source§

impl<T: FftNum> Fft<T> for Butterfly31<T>

source§

impl<T: FftNum> Fft<T> for Butterfly32<T>

source§

impl<T: FftNum> Fft<T> for BluesteinsAlgorithm<T>

source§

impl<T: FftNum> Fft<T> for Dft<T>

source§

impl<T: FftNum> Fft<T> for GoodThomasAlgorithm<T>

source§

impl<T: FftNum> Fft<T> for GoodThomasAlgorithmSmall<T>

source§

impl<T: FftNum> Fft<T> for MixedRadix<T>

source§

impl<T: FftNum> Fft<T> for MixedRadixSmall<T>

source§

impl<T: FftNum> Fft<T> for RadersAlgorithm<T>

source§

impl<T: FftNum> Fft<T> for Radix3<T>

source§

impl<T: FftNum> Fft<T> for Radix4<T>