pub struct Plan2D<T: Float> { /* private fields */ }Expand description
A plan for executing 2D FFT transforms.
Implements row-column decomposition: apply 1D FFT to all rows,
then to all columns. When the threading feature is enabled,
row and column passes are executed in parallel using rayon’s
work-stealing scheduler. Supply a custom pool via
Plan2D::with_rayon_pool to isolate FFT work from other rayon
tasks in the same process.
Implementations§
Source§impl<T: Float> Plan2D<T>
impl<T: Float> Plan2D<T>
Sourcepub fn new(
n0: usize,
n1: usize,
direction: Direction,
flags: Flags,
) -> Option<Self>
pub fn new( n0: usize, n1: usize, direction: Direction, flags: Flags, ) -> Option<Self>
Create a 2D complex-to-complex DFT plan.
§Arguments
n0- Number of rowsn1- Number of columnsdirection- Forward or Backward transformflags- Planning flags
§Returns
A plan that can be executed on row-major input/output buffers of size n0 × n1.
§Examples
use oxifft::{Complex, Direction, Flags, Plan2D};
// 4×4 2D forward FFT
let plan = Plan2D::<f64>::new(4, 4, Direction::Forward, Flags::ESTIMATE)
.expect("plan construction failed");
// All-ones input: DC bin = 16
let input = vec![Complex::<f64>::new(1.0, 0.0); 16];
let mut output = vec![Complex::<f64>::zero(); 16];
plan.execute(&input, &mut output);
// DC bin (index 0) = sum of all 16 elements
assert!((output[0].re - 16.0_f64).abs() < 1e-9);
// All non-DC bins should be zero for constant input
assert!(output[1].re.abs() < 1e-9);Sourcepub fn with_rayon_pool(self, pool: Arc<ThreadPool>) -> Self
pub fn with_rayon_pool(self, pool: Arc<ThreadPool>) -> Self
Override the rayon thread pool used for parallel row/column transforms.
By default Plan2D uses the global rayon pool. Pass a dedicated pool
here to keep FFT work isolated from other parallel tasks in the process.
Requires the threading feature to be enabled.
Sourcepub fn execute(&self, input: &[Complex<T>], output: &mut [Complex<T>])
pub fn execute(&self, input: &[Complex<T>], output: &mut [Complex<T>])
Execute the 2D FFT on the given input/output buffers.
Input and output are row-major: element at (i, j) is at index i*n1 + j.
When the threading feature is enabled, row transforms are parallelised
over rayon workers using work-stealing; column transforms are parallelised
similarly with per-thread scratch buffers.
§Panics
Panics if buffer sizes don’t match n0 × n1.
Sourcepub fn execute_inplace(&self, data: &mut [Complex<T>])
pub fn execute_inplace(&self, data: &mut [Complex<T>])
Execute the 2D FFT in-place.
When the threading feature is enabled, both the row and column passes
are parallelised over rayon workers.
§Panics
Panics if buffer size doesn’t match n0 × n1.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Plan2D<T>
impl<T> !RefUnwindSafe for Plan2D<T>
impl<T> Send for Plan2D<T>
impl<T> Sync for Plan2D<T>
impl<T> Unpin for Plan2D<T>
impl<T> UnsafeUnpin for Plan2D<T>
impl<T> !UnwindSafe for Plan2D<T>
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