pub struct GuruPlan<T: Float> { /* private fields */ }Expand description
Guru interface for maximum flexibility.
Allows specifying arbitrary dimensions, strides, and batch parameters. This is the most general FFT interface, supporting:
- Arbitrary transform dimensions (1D, 2D, 3D, ND)
- Arbitrary strides for input and output
- Batched transforms with arbitrary batch dimensions
- In-place or out-of-place operation
§Example
use oxifft::{Complex, Direction, Flags, IoDim, Tensor};
use oxifft::api::GuruPlan;
// Create a batched 1D FFT: 10 transforms of size 256
let dims = Tensor::new(vec![IoDim::contiguous(256)]);
let howmany = Tensor::new(vec![IoDim::new(10, 256, 256)]); // 10 batches, stride=256
let input = vec![Complex::new(0.0, 0.0); 2560];
let mut output = vec![Complex::new(0.0, 0.0); 2560];
let plan = GuruPlan::<f64>::dft(
&dims,
&howmany,
Direction::Forward,
Flags::ESTIMATE,
)
.expect("valid guru plan");
plan.execute(&input, &mut output);Implementations§
Source§impl<T: Float> GuruPlan<T>
impl<T: Float> GuruPlan<T>
Sourcepub fn dft(
dims: &Tensor,
howmany: &Tensor,
direction: Direction,
flags: Flags,
) -> Option<Self>
pub fn dft( dims: &Tensor, howmany: &Tensor, direction: Direction, flags: Flags, ) -> Option<Self>
Create a guru DFT plan with full control over dimensions and strides.
§Arguments
dims- Transform dimensions with input/output strideshowmany- Batch dimensions (vector rank). Can be empty for single transform.direction- Forward or Backwardflags- Planning flags
§Returns
A plan that can be executed on buffers with the specified layout.
Returns None if any dimension has size 0.
§Memory Layout
dimsspecifies the transform dimensions (innermost dimensions transform)howmanyspecifies the batch dimensions (outermost dimensions iterate)- Strides can be different for input and output (for in-place: use same strides)
§Examples
use oxifft::{Complex, Direction, Flags, GuruPlan, Tensor};
// Simple 1D forward FFT via the guru interface
let dims = Tensor::rank1(8);
let howmany = Tensor::empty();
let plan = GuruPlan::<f64>::dft(&dims, &howmany, Direction::Forward, Flags::ESTIMATE)
.expect("plan construction failed");
let input = vec![Complex::<f64>::new(1.0, 0.0); 8];
let mut output = vec![Complex::<f64>::zero(); 8];
plan.execute(&input, &mut output);
// DC bin = sum of all ones = 8
assert!((output[0].re - 8.0_f64).abs() < 1e-9);Sourcepub fn transform_size(&self) -> usize
pub fn transform_size(&self) -> usize
Get the total number of elements in one transform.
Sourcepub fn batch_count(&self) -> usize
pub fn batch_count(&self) -> usize
Get the total number of transforms (batch count).
Sourcepub fn execute(&self, input: &[Complex<T>], output: &mut [Complex<T>])
pub fn execute(&self, input: &[Complex<T>], output: &mut [Complex<T>])
Execute the guru plan on the given buffers.
§Arguments
input- Input buffer with layout matchingdimsandhowmanyoutput- Output buffer with layout matchingdimsandhowmany
§Panics
Panics if buffers are too small for the specified layout.
Panics, in both debug and release builds and with a diagnostic
naming the offending index, if a computed element offset is negative.
This can happen when crate::IoDim strides are negative and the batch
index is large enough that base_offset + i * stride < 0; the check
used to be debug_assert!-only, so release builds reported it as an
opaque near-usize::MAX slice-index panic instead.
Always ensure that for every element i in 0..n, the expression
in_offset + i * is and out_offset + i * os evaluate to a
non-negative value.
Sourcepub fn execute_inplace(&self, data: &mut [Complex<T>])
pub fn execute_inplace(&self, data: &mut [Complex<T>])
Execute the plan in-place.
For in-place execution, input and output strides must be identical.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for GuruPlan<T>
impl<T> RefUnwindSafe for GuruPlan<T>where
T: RefUnwindSafe,
impl<T> Send for GuruPlan<T>
impl<T> Sync for GuruPlan<T>
impl<T> Unpin for GuruPlan<T>
impl<T> UnsafeUnpin for GuruPlan<T>
impl<T> UnwindSafe for GuruPlan<T>where
T: UnwindSafe,
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