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
impl FftPlan
Sourcepub fn new(size: usize) -> FerrayResult<Self>
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.
Sourcepub fn execute(
&self,
signal: &Array<Complex<f64>, Ix1>,
) -> FerrayResult<Array<Complex<f64>, Ix1>>
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.
Sourcepub fn execute_with_norm(
&self,
signal: &Array<Complex<f64>, Ix1>,
norm: FftNorm,
) -> FerrayResult<Array<Complex<f64>, Ix1>>
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.
Sourcepub fn execute_inverse(
&self,
spectrum: &Array<Complex<f64>, Ix1>,
) -> FerrayResult<Array<Complex<f64>, Ix1>>
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FftPlan
impl !RefUnwindSafe for FftPlan
impl Send for FftPlan
impl Sync for FftPlan
impl Unpin for FftPlan
impl UnsafeUnpin for FftPlan
impl !UnwindSafe for FftPlan
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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