Skip to main content

FftPlan

Struct FftPlan 

Source
pub struct FftPlan { /* private fields */ }
Expand description

A reusable FFT plan for a specific transform size.

FftPlan caches the internal FFT algorithm for a given size, enabling efficient repeated transforms. Plans are Send + Sync and can be shared across threads.

§Example

use ferray_fft::FftPlan;
use ferray_core::{Array, Ix1};
use num_complex::Complex;

let plan = FftPlan::new(8).unwrap();
let signal = Array::<Complex<f64>, Ix1>::from_vec(
    Ix1::new([8]),
    vec![Complex::new(1.0, 0.0); 8],
).unwrap();
let result = plan.execute(&signal).unwrap();
assert_eq!(result.shape(), &[8]);

Implementations§

Source§

impl FftPlan

Source

pub fn new(size: usize) -> FerrayResult<Self>

Create a new FFT plan for the given transform size.

The plan pre-computes the internal FFT algorithm so that subsequent calls to execute and execute_inverse are fast.

§Errors

Returns FerrayError::InvalidValue if size is 0.

Source

pub fn size(&self) -> usize

Return the transform size this plan was created for.

Source

pub fn execute( &self, signal: &Array<Complex<f64>, Ix1>, ) -> FerrayResult<Array<Complex<f64>, Ix1>>

Execute a forward FFT on the given signal.

The input array must have exactly self.size() elements. Uses FftNorm::Backward (no scaling on forward).

§Errors

Returns FerrayError::ShapeMismatch if the input length does not match the plan size.

Source

pub fn execute_with_norm( &self, signal: &Array<Complex<f64>, Ix1>, norm: FftNorm, ) -> FerrayResult<Array<Complex<f64>, Ix1>>

Execute a forward FFT with the specified normalization.

§Errors

Returns FerrayError::ShapeMismatch if the input length does not match the plan size.

Source

pub fn execute_inverse( &self, spectrum: &Array<Complex<f64>, Ix1>, ) -> FerrayResult<Array<Complex<f64>, Ix1>>

Execute an inverse FFT on the given spectrum.

Uses FftNorm::Backward (divides by n on inverse).

§Errors

Returns FerrayError::ShapeMismatch if the input length does not match the plan size.

Source

pub fn execute_inverse_with_norm( &self, spectrum: &Array<Complex<f64>, Ix1>, norm: FftNorm, ) -> FerrayResult<Array<Complex<f64>, Ix1>>

Execute an inverse FFT with the specified normalization.

§Errors

Returns FerrayError::ShapeMismatch if the input length does not match the plan size.

Trait Implementations§

Source§

impl Debug for FftPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.