pub struct FftPlannerSse<T: FftNum> { /* private fields */ }Expand description
The SSE FFT planner creates new FFT algorithm instances using a mix of scalar and SSE accelerated algorithms. It requires at least SSE4.1, which is available on all reasonably recent x86_64 cpus.
RustFFT has several FFT algorithms available. For a given FFT size, the FftPlannerSse decides which of the
available FFT algorithms to use and then initializes them.
// Perform a forward Fft of size 1234
use std::sync::Arc;
use rustfft::{FftPlannerSse, num_complex::Complex};
if let Ok(mut planner) = FftPlannerSse::new() {
let fft = planner.plan_fft_forward(1234);
let mut buffer = vec![Complex{ re: 0.0f32, im: 0.0f32 }; 1234];
fft.process(&mut buffer);
// The FFT instance returned by the planner has the type `Arc<dyn Fft<T>>`,
// where T is the numeric type, ie f32 or f64, so it's cheap to clone
let fft_clone = Arc::clone(&fft);
}If you plan on creating multiple FFT instances, it is recommended to re-use the same planner for all of them. This is because the planner re-uses internal data across FFT instances wherever possible, saving memory and reducing setup time. (FFT instances created with one planner will never re-use data and buffers with FFT instances created by a different planner)
Each FFT instance owns Arcs to its internal data, rather than borrowing it from the planner, so it’s perfectly
safe to drop the planner after creating Fft instances.
Implementations§
Source§impl<T: FftNum> FftPlannerSse<T>
impl<T: FftNum> FftPlannerSse<T>
Sourcepub fn new() -> Result<Self, ()>
pub fn new() -> Result<Self, ()>
Creates a new FftPlannerSse instance.
Returns Ok(planner_instance) if we’re compiling for X86_64, SSE support was enabled in feature flags, and the current CPU supports the sse4.1 CPU feature.
Returns Err(()) if SSE support is not available.
Sourcepub fn plan_fft(
&mut self,
len: usize,
direction: FftDirection,
) -> Arc<dyn Fft<T>>
pub fn plan_fft( &mut self, len: usize, direction: FftDirection, ) -> Arc<dyn Fft<T>>
Returns a Fft instance which uses SSE4.1 instructions to compute FFTs of size len.
If the provided direction is FftDirection::Forward, the returned instance will compute forward FFTs. If it’s FftDirection::Inverse, it will compute inverse FFTs.
If this is called multiple times, the planner will attempt to re-use internal data between calls, reducing memory usage and FFT initialization time.
Sourcepub fn plan_fft_forward(&mut self, len: usize) -> Arc<dyn Fft<T>>
pub fn plan_fft_forward(&mut self, len: usize) -> Arc<dyn Fft<T>>
Returns a Fft instance which uses SSE4.1 instructions to compute forward FFTs of size len
If this is called multiple times, the planner will attempt to re-use internal data between calls, reducing memory usage and FFT initialization time.
Sourcepub fn plan_fft_inverse(&mut self, len: usize) -> Arc<dyn Fft<T>>
pub fn plan_fft_inverse(&mut self, len: usize) -> Arc<dyn Fft<T>>
Returns a Fft instance which uses SSE4.1 instructions to compute inverse FFTs of size `len.
If this is called multiple times, the planner will attempt to re-use internal data between calls, reducing memory usage and FFT initialization time.