Trait rustfft::Fft

source ·
pub trait Fft<T: FftNum>: Length + Direction + Sync + Send {
    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; 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

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

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

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.

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

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