[][src]Struct rustfft::FftPlannerAvx

pub struct FftPlannerAvx<T: FftNum> { /* fields omitted */ }

The AVX FFT planner creates new FFT algorithm instances which take advantage of the AVX instruction set.

Creating an instance of FftPlannerAvx requires the avx and fma instructions to be available on the current machine, and it requires RustFFT's avx feature flag to be set. A few algorithms will use avx2 if it's available, but it isn't required.

For the time being, AVX acceleration is black box, and AVX accelerated algorithms are not available without a planner. This may change in the future.

// Perform a forward Fft of size 1234, accelerated by AVX
use std::sync::Arc;
use rustfft::{FftPlannerAvx, num_complex::Complex};

// If FftPlannerAvx::new() returns Ok(), we'll know AVX algorithms are available
// on this machine, and that RustFFT was compiled with the `avx` feature flag
if let Ok(mut planner) = FftPlannerAvx::new() {
    let fft = planner.plan_fft_forward(1234);

    let mut buffer = vec![Complex{ re: 0.0f32, im: 0.0f32 }; 1234];
    fft.process_inplace(&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 reuse 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

impl<T: FftNum> FftPlannerAvx<T>[src]

pub fn new() -> Result<Self, ()>[src]

Constructs a new FftPlannerAvx instance.

Returns Ok(planner_instance) if this machine has the required instruction sets and the avx feature flag is set. Returns Err(()) if some instruction sets are missing, or if the avx feature flag is not set.

pub fn plan_fft(
    &mut self,
    _len: usize,
    _direction: FftDirection
) -> Arc<dyn Fft<T>>
[src]

Returns a Fft instance which uses AVX 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.

pub fn plan_fft_forward(&mut self, _len: usize) -> Arc<dyn Fft<T>>[src]

Returns a Fft instance which uses AVX 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.

pub fn plan_fft_inverse(&mut self, _len: usize) -> Arc<dyn Fft<T>>[src]

Returns a Fft instance which uses AVX 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.

Auto Trait Implementations

impl<T> RefUnwindSafe for FftPlannerAvx<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for FftPlannerAvx<T>[src]

impl<T> Sync for FftPlannerAvx<T>[src]

impl<T> Unpin for FftPlannerAvx<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for FftPlannerAvx<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.