### Slice::len Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Demonstrates how to get the number of elements in a slice. ```rust let a = [1, 2, 3]; assert_eq!(a.len(), 3); ``` -------------------------------- ### Get Metadata with Path and Handle Errors Source: https://docs.rs/fftw/latest/fftw/error/type.Result.html Shows how to get file metadata using Path and handle potential errors, such as non-existent paths. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Complex-to-Real Transformation Example Source: https://docs.rs/fftw/latest/fftw/index.html Demonstrates how to perform a complex-to-real Fast Fourier Transform using the fftw crate. ```APIDOC ## Complex-to-Real Transformation ### Description Performs a complex-to-real Fast Fourier Transform. ### Method `c2r` ### Endpoint N/A (Library function) ### Parameters N/A (Library function) ### Request Example ```rust use fftw::array::AlignedVec; use fftw::plan::C2RPlan; use fftw::types::C64; use std::f64::consts::PI; let n = 128; let mut c2r: fftw::plan::C2RPlan64 = C2RPlan::aligned(&[n], fftw::flag::Flag::MEASURE).unwrap(); let mut a = AlignedVec::new(n / 2 + 1); let mut b = AlignedVec::new(n); for i in 0..(n / 2 + 1) { a[i] = c64::new(1.0, 0.0); } c2r.c2r(&mut a, &mut b).unwrap(); ``` ### Response N/A (Library function) ### Response Example N/A (Library function) ``` -------------------------------- ### Complex-to-Complex Transformation Example Source: https://docs.rs/fftw/latest/fftw/index.html Demonstrates how to perform a complex-to-complex Fast Fourier Transform using the fftw crate. ```APIDOC ## Complex-to-Complex Transformation ### Description Performs a complex-to-complex Fast Fourier Transform. ### Method `c2c` ### Endpoint N/A (Library function) ### Parameters N/A (Library function) ### Request Example ```rust use fftw::array::AlignedVec; use fftw::plan::C2CPlan; use fftw::types::{C64, Sign}; use std::f64::consts::PI; let n = 128; let mut plan: fftw::plan::C2CPlan64 = C2CPlan::aligned(&[n], Sign::Forward, fftw::flag::Flag::MEASURE).unwrap(); let mut a = AlignedVec::new(n); let mut b = AlignedVec::new(n); let k0 = 2.0 * PI / n as f64; for i in 0..n { a[i] = c64::new((k0 * i as f64).cos(), 0.0); } plan.c2c(&mut a, &mut b).unwrap(); ``` ### Response N/A (Library function) ### Response Example N/A (Library function) ``` -------------------------------- ### Slice::split_first Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a slice into its first element and the rest of the slice. ```rust let x = &[0, 1, 2]; if let Some((first, elements)) = x.split_first() { assert_eq!(first, &0); assert_eq!(elements, &[1, 2]); } ``` -------------------------------- ### Slice::is_empty Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Shows how to check if a slice is empty. ```rust let a = [1, 2, 3]; assert!(!a.is_empty()); let b: &[i32] = &[]; assert!(b.is_empty()); ``` -------------------------------- ### Slice Starts With Method Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Checks if a slice begins with a specified prefix slice. ```APIDOC ## GET /slice/starts_with ### Description Returns `true` if `needle` is a prefix of the slice or equal to the slice. Always returns `true` if `needle` is an empty slice. ### Method GET ### Endpoint `/slice/starts_with` ### Parameters #### Query Parameters - **slice** (array) - Required - The slice to check. - **needle** (array) - Required - The prefix slice to compare against. ### Request Example ```json { "slice": [10, 40, 30], "needle": [10, 40] } ``` ### Response #### Success Response (200) - **result** (boolean) - `true` if the slice starts with the needle, `false` otherwise. #### Response Example ```json { "result": true } ``` ``` -------------------------------- ### Display and Default Implementations Source: https://docs.rs/fftw/latest/fftw/types/type.c64.html Shows how Complex numbers can be formatted for display and how to get their default value. ```APIDOC ## Display for Complex ### Description Implements the `Display` trait for `Complex`, allowing it to be formatted using a formatter. ### Method `fmt` ### Parameters - `f` (*Formatter<'_>*) - A mutable reference to a formatter. ### Response - `Result<(), Error>` - Indicates success or failure of the formatting operation. ## Default for Complex ### Description Implements the `Default` trait for `Complex`. ### Method `default` ### Response - `Complex` - Returns the default value for `Complex`. ``` -------------------------------- ### Slice::first Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Retrieves the first element of a slice if it exists. ```rust let v = [10, 40, 30]; assert_eq!(Some(&10), v.first()); let w: &[i32] = &[]; assert_eq!(None, w.first()); ``` -------------------------------- ### Slice::split_first_mut Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a mutable slice into its first element and the rest of the slice. ```rust let x = &mut [0, 1, 2]; if let Some((first, elements)) = x.split_first_mut() { *first = 3; elements[0] = 4; elements[1] = 5; } assert_eq!(x, &[3, 4, 5]); ``` -------------------------------- ### Slice::split_last Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a slice into its last element and the preceding elements. ```rust let x = &[0, 1, 2]; if let Some((last, elements)) = x.split_last() { assert_eq!(last, &2); assert_eq!(elements, &[0, 1]); } ``` -------------------------------- ### Use `unwrap_or_else` with a Closure Source: https://docs.rs/fftw/latest/fftw/error/type.Result.html Demonstrates getting the `Ok` value or computing a default value using a closure if the Result is an `Err`. ```rust fn count(x: &str) -> usize { x.len() } assert_eq!(Ok(2).unwrap_or_else(count), 2); assert_eq!(Err("foo").unwrap_or_else(count), 3); ``` -------------------------------- ### Providing a Default Value with `unwrap_or` Source: https://docs.rs/fftw/latest/fftw/error/type.Result.html Demonstrates how to get the `Ok` value or a default value if the `Result` is `Err` using `unwrap_or`. ```APIDOC ## `unwrap_or` Example ### Description Returns the contained `Ok` value or a provided default. Arguments passed to `unwrap_or` are eagerly evaluated. ### Method `unwrap_or` ### Endpoint N/A (Method on `Result` type) ### Request Body N/A ### Request Example ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` ### Response #### Success Response Returns the `Ok` value if `self` is `Ok`. #### Response Example ```rust 9 ``` #### Default Value Response Returns the `default` value if `self` is `Err`. #### Response Example ```rust 2 ``` ``` -------------------------------- ### Check if a slice starts with a prefix Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Use `starts_with` to verify if a slice begins with a specific sequence of elements. It always returns `true` if the `needle` is an empty slice. ```rust let v = [10, 40, 30]; assert!(v.starts_with(&[10])); assert!(v.starts_with(&[10, 40])); assert!(v.starts_with(&v)); assert!(!v.starts_with(&[50])); assert!(!v.starts_with(&[10, 50])); ``` ```rust let v = &[10, 40, 30]; assert!(v.starts_with(&[])); let v: &[u8] = &[]; assert!(v.starts_with(&[])); ``` -------------------------------- ### FFTW Complex-to-Real Transformation Source: https://docs.rs/fftw/latest/fftw/index.html Performs a complex-to-real Fast Fourier Transform using FFTW. Requires specific imports and setup. ```rust use fftw::array::AlignedVec; use fftw::plan::*; use fftw::types::*; use std::f64::consts::PI; let n = 128; let mut c2r: C2RPlan64 = C2RPlan::aligned(&[n], Flag::MEASURE).unwrap(); let mut a = AlignedVec::new(n / 2 + 1); let mut b = AlignedVec::new(n); for i in 0..(n / 2 + 1) { a[i] = c64::new(1.0, 0.0); } c2r.c2r(&mut a, &mut b).unwrap(); ``` -------------------------------- ### Slice::first_chunk Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an array reference to the first N items in the slice. Returns None if the slice is shorter than N. ```rust let u = [10, 40, 30]; assert_eq!(Some(&[10, 40]), u.first_chunk::<2>()); let v: &[i32] = &[10]; assert_eq!(None, v.first_chunk::<2>()); let w: &[i32] = &[]; assert_eq!(Some(&[]), w.first_chunk::<0>()); ``` -------------------------------- ### Use `unwrap_or` with a Default Value Source: https://docs.rs/fftw/latest/fftw/error/type.Result.html Shows how to get the `Ok` value or a provided default value if the Result is an `Err`. The default is eagerly evaluated. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### Iterate Over Slice Elements in Rust Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Use `iter()` to get an immutable iterator over slice elements. The iterator yields items from start to end. ```rust let x = &[1, 2, 4]; let mut iterator = x.iter(); assert_eq!(iterator.next(), Some(&1)); assert_eq!(iterator.next(), Some(&2)); assert_eq!(iterator.next(), Some(&4)); assert_eq!(iterator.next(), None); ``` -------------------------------- ### C2RPlan new Method Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2RPlan.html Creates a new complex-to-real plan. Requires shape, input complex slice, output real slice, and transformation flags. ```rust fn new( shape: &[usize], in_: &mut [Self::Complex], out: &mut [Self::Real], flag: Flag, ) -> Result ``` -------------------------------- ### Plan Implementations Source: https://docs.rs/fftw/latest/fftw/plan/struct.Plan.html Shows blanket implementations for Plan for various traits. ```APIDOC ## impl Freeze for Plan ### Description Blanket implementation of the Freeze trait for Plan. ### Method N/A (Blanket Implementation) ### Endpoint N/A ## impl RefUnwindSafe for Plan ### Description Blanket implementation of the RefUnwindSafe trait for Plan. ### Method N/A (Blanket Implementation) ### Endpoint N/A ## impl !Send for Plan ### Description Blanket implementation of the !Send trait (negated Send) for Plan. ### Method N/A (Blanket Implementation) ### Endpoint N/A ## impl Sync for Plan ### Description Blanket implementation of the Sync trait for Plan. ### Method N/A (Blanket Implementation) ### Endpoint N/A ## impl Unpin for Plan ### Description Blanket implementation of the Unpin trait for Plan. ### Method N/A (Blanket Implementation) ### Endpoint N/A ## impl UnwindSafe for Plan ### Description Blanket implementation of the UnwindSafe trait for Plan. ### Method N/A (Blanket Implementation) ### Endpoint N/A ``` -------------------------------- ### rchunks Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an iterator over chunk_size elements starting at the end. ```APIDOC ## rchunks ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. The chunks are slices and do not overlap. ### Parameters - **chunk_size** (usize) - Required - The size of the chunks. ### Panics - Panics if `chunk_size` is zero. ``` -------------------------------- ### Slice::split_first_chunk Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an array reference to the first N items in the slice and the remaining slice. Returns None if the slice is shorter than N. ```rust pub fn split_first_chunk(&self) -> Option<(&[T; N], &[T])> ``` -------------------------------- ### pub fn windows(&self, size: usize) Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an iterator over all contiguous windows of length size. ```APIDOC ## pub fn windows(&self, size: usize) ### Description Returns an iterator over all contiguous windows of length `size`. The windows overlap. If the slice is shorter than `size`, the iterator returns no values. ### Parameters #### Path Parameters - **size** (usize) - Required - The length of the windows. ``` -------------------------------- ### as_rchunks_mut Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits the slice into a slice of N-element arrays starting from the end. ```APIDOC ## as_rchunks_mut ### Description Splits the slice into a slice of `N`-element arrays, starting at the end of the slice, and a remainder slice with length strictly less than `N`. ### Parameters - **N** (const usize) - Required - The size of the chunks. ### Panics - Panics if `N` is zero. ``` -------------------------------- ### Slice::last Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Retrieves the last element of a slice if it exists. ```rust let v = [10, 40, 30]; assert_eq!(Some(&30), v.last()); let w: &[i32] = &[]; assert_eq!(None, w.last()); ``` -------------------------------- ### R2RPlan32::new Source: https://docs.rs/fftw/latest/fftw/plan/type.R2RPlan32.html Creates a new real-to-real plan for 32-bit floating point data. ```APIDOC ## R2RPlan32::new ### Description Creates a new real-to-real plan for 32-bit floating point data. ### Parameters - **shape** (&[usize]) - Required - The dimensions of the transform. - **in_** (&mut [f32]) - Required - Input buffer. - **out_** (&mut [f32]) - Required - Output buffer. - **kind** (R2RKind) - Required - The type of R2R transform. - **flag** (Flag) - Required - FFTW planning flags. ### Response - **Result** - Returns the new plan or an error. ``` -------------------------------- ### Retrieve Slice Metadata Source: https://docs.rs/fftw/latest/src/fftw/plan.rs.html Utility function to get the length and alignment of a slice. ```rust fn slice_info(a: &[T]) -> (usize, Alignment) { (a.len(), alignment_of(a)) } ``` -------------------------------- ### FFTW Flag Initialization Methods Source: https://docs.rs/fftw/latest/fftw/types/struct.Flag.html Methods for creating Flag values, including empty, all flags, and from bit representations. ```rust pub const fn empty() -> Self ``` ```rust pub const fn all() -> Self ``` ```rust pub const fn from_bits(bits: u32) -> Option ``` ```rust pub const fn from_bits_truncate(bits: u32) -> Self ``` ```rust pub const fn from_bits_retain(bits: u32) -> Self ``` ```rust pub fn from_name(name: &str) -> Option ``` -------------------------------- ### R2RPlan::new Source: https://docs.rs/fftw/latest/fftw/plan/trait.R2RPlan.html Creates a new real-to-real transform plan. ```APIDOC ## fn new ### Description Creates a new plan for a real-to-real transform. ### Parameters - **shape** (&[usize]) - Required - The dimensions of the transform. - **in_** (&mut [Self::Real]) - Required - Input buffer. - **out_** (&mut [Self::Real]) - Required - Output buffer. - **kind** (R2RKind) - Required - The type of R2R transform. - **flag** (Flag) - Required - FFTW planning flags. ### Response - **Result** - Returns the new plan or an error if creation fails. ``` -------------------------------- ### C2RPlan64 API Source: https://docs.rs/fftw/latest/fftw/plan/type.C2RPlan64.html Methods for creating and executing complex-to-real FFTW plans. ```APIDOC ## C2RPlan64 ### Description A type alias for Plan used to perform complex-to-real transforms. ### Methods - **new(shape: &[usize], in_: &mut [Self::Complex], out: &mut [Self::Real], flag: Flag) -> Result** Creates a new plan for the specified shape and buffers. - **c2r(&mut self, in_: &mut [Self::Complex], out: &mut [Self::Real]) -> Result<()>** Executes the complex-to-real transform using the provided buffers. - **aligned(shape: &[usize], flag: Flag) -> Result** Creates a new plan with aligned vector memory allocation. ``` -------------------------------- ### C2RPlan::c2r Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2RPlan.html Executes the complex-to-real transformation using the initialized plan. ```APIDOC ## fn c2r ### Description Executes the complex-to-real transform on the provided buffers. ### Parameters - **in_** (&mut [Self::Complex]) - Required - Input buffer for complex data. - **out** (&mut [Self::Real]) - Required - Output buffer for real data. ### Response - **Result<()>** - Returns Ok(()) on success or an error. ``` -------------------------------- ### Get Imaginary Unit Source: https://docs.rs/fftw/latest/fftw/types/type.c64.html Returns the imaginary unit `i`. This is an alternative to the `Complex::I` constant. ```rust pub fn i() -> Complex; ``` -------------------------------- ### Slice::last_mut Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Provides mutable access to the last element of a slice, if it exists. ```rust let x = &mut [0, 1, 2]; if let Some(last) = x.last_mut() { *last = 10; } assert_eq!(x, &[0, 1, 10]); let y: &mut [i32] = &mut []; assert_eq!(None, y.last_mut()); ``` -------------------------------- ### R2RPlan new Method Source: https://docs.rs/fftw/latest/fftw/plan/trait.R2RPlan.html Creates a new R2RPlan. Requires specifying the shape of the transform, input and output buffers, the type of transform (R2RKind), and FFTW flags. ```rust fn new( shape: &[usize], in_: &mut [Self::Real], out: &mut [Self::Real], kind: R2RKind, flag: Flag, ) -> Result ``` -------------------------------- ### Slice::split_last_mut Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a mutable slice into its last element and the preceding elements. ```rust let x = &mut [0, 1, 2]; if let Some((last, elements)) = x.split_last_mut() { *last = 3; elements[0] = 4; elements[1] = 5; } assert_eq!(x, &[4, 5, 3]); ``` -------------------------------- ### Perform Complex-to-Real FFT Source: https://docs.rs/fftw/latest/index.html Demonstrates executing a complex-to-real transform using an aligned C2RPlan. ```rust use fftw::array::AlignedVec; use fftw::plan::*; use fftw::types::*; use std::f64::consts::PI; let n = 128; let mut c2r: C2RPlan64 = C2RPlan::aligned(&[n], Flag::MEASURE).unwrap(); let mut a = AlignedVec::new(n / 2 + 1); let mut b = AlignedVec::new(n); for i in 0..(n / 2 + 1) { a[i] = c64::new(1.0, 0.0); } c2r.c2r(&mut a, &mut b).unwrap(); ``` -------------------------------- ### Perform Complex-to-Complex FFT Source: https://docs.rs/fftw/latest/index.html Demonstrates setting up an aligned plan and executing a forward complex-to-complex transform on an AlignedVec. ```rust use fftw::array::AlignedVec; use fftw::plan::*; use fftw::types::*; use std::f64::consts::PI; let n = 128; let mut plan: C2CPlan64 = C2CPlan::aligned(&[n], Sign::Forward, Flag::MEASURE).unwrap(); let mut a = AlignedVec::new(n); let mut b = AlignedVec::new(n); let k0 = 2.0 * PI / n as f64; for i in 0..n { a[i] = c64::new((k0 * i as f64).cos(), 0.0); } plan.c2c(&mut a, &mut b).unwrap(); ``` -------------------------------- ### Slice::first_mut Example Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Provides mutable access to the first element of a slice, if it exists. ```rust let x = &mut [0, 1, 2]; if let Some(first) = x.first_mut() { *first = 5; } assert_eq!(x, &[5, 1, 2]); let y: &mut [i32] = &mut []; assert_eq!(None, y.first_mut()); ``` -------------------------------- ### SIMD Slice Splitting with as_simd Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Illustrates splitting a slice into prefix, middle (SIMD types), and suffix using `as_simd`. This is a nightly-only experimental API. It handles cases where there aren't enough elements for a full SIMD type. ```rust #![feature(portable_simd)] use core::simd::prelude::*; let short = &[1, 2, 3]; let (prefix, middle, suffix) = short.as_simd::<4>(); assert_eq!(middle, []); // Not enough elements for anything in the middle // They might be split in any possible way between prefix and suffix let it = prefix.iter().chain(suffix).copied(); assert_eq!(it.collect::>(), vec![1, 2, 3]); fn basic_simd_sum(x: &[f32]) -> f32 { use std::ops::Add; let (prefix, middle, suffix) = x.as_simd(); let sums = f32x4::from_array([ prefix.iter().copied().sum(), 0.0, 0.0, suffix.iter().copied().sum(), ]); let sums = middle.iter().copied().fold(sums, f32x4::add); sums.reduce_sum() } let numbers: Vec = (1..101).map(|x| x as _).collect(); assert_eq!(basic_simd_sum(&numbers[1..99]), 4949.0); ``` -------------------------------- ### Split slice from the end Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a slice into a remainder and fixed-size arrays starting from the end of the slice. ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let (remainder, chunks) = slice.as_rchunks(); assert_eq!(remainder, &['l']); assert_eq!(chunks, &[['o', 'r'], ['e', 'm']]); ``` -------------------------------- ### Plan64 Trait Implementations Source: https://docs.rs/fftw/latest/fftw/plan/type.Plan64.html Provides details on the trait implementations for the Plan64 type. ```APIDOC ## Trait Implementations for Plan64 ### `impl PlanSpec for Plan64` #### `fn validate(self) -> Result` Validates the plan. #### `fn destroy(self)` Destroys the plan. #### `fn print(self)` Prints the plan. ``` -------------------------------- ### pub fn iter(&self) Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an iterator over the slice yielding all items from start to end. ```APIDOC ## pub fn iter(&self) ### Description Returns an iterator over the slice. The iterator yields all items from start to end. ### Parameters #### Path Parameters - **self** - Required - The slice to iterate over. ``` -------------------------------- ### C2RPlan::aligned Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2RPlan.html Creates a new plan with aligned memory allocation. ```APIDOC ## fn aligned ### Description Creates a new plan with aligned vector allocation. ### Parameters - **shape** (&[usize]) - Required - The shape of the transformation. - **flag** (Flag) - Required - FFTW planning flags. ### Response - **Result** - Returns the initialized plan or an error. ``` -------------------------------- ### get Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns a reference to an element or subslice depending on the type of index. Returns None if the index is out of bounds. ```APIDOC ## get ### Description Returns a reference to an element or subslice depending on the type of index. If given a position, returns a reference to the element at that position or `None` if out of bounds. If given a range, returns the subslice corresponding to that range, or `None` if out of bounds. ### Method GET (conceptual) ### Endpoint N/A (method on slice) ### Parameters #### Path Parameters - **index** (I: SliceIndex<[T]>) - Required - The index or range to access. ### Request Example ```rust let v = [10, 40, 30]; assert_eq!(Some(&40), v.get(1)); assert_eq!(Some(&[10, 40][..]), v.get(0..2)); assert_eq!(None, v.get(3)); assert_eq!(None, v.get(0..4)); ``` ### Response #### Success Response (200) - **Option<&>::Output>** - A reference to the element or subslice, or None if out of bounds. #### Response Example ```json // Conceptual representation of accessing an element { "value": 40 } // Conceptual representation of accessing a subslice { "subslice": [10, 40] } ``` ``` -------------------------------- ### Plan Trait Implementations Source: https://docs.rs/fftw/latest/fftw/plan/type.C2CPlan64.html Provides implementations for the Plan trait for complex-to-complex transforms with 64-bit precision. ```APIDOC ### impl C2CPlan for Plan #### Description Implements the `C2CPlan` trait for `Plan`. #### Type Alias: Complex ```rust type Complex = Complex; ``` #### Function: new ```rust fn new( shape: &[usize], in_: &mut [Self::Complex], out: &mut [Self::Complex], sign: Sign, flag: Flag, ) -> Result ``` ##### Description Create a new plan for complex-to-complex transform. #### Function: c2c ```rust fn c2c( &mut self, in_: &mut [Self::Complex], out: &mut [Self::Complex], ) -> Result<()> ``` ##### Description Execute the complex-to-complex transform using the created plan. #### Function: aligned ```rust fn aligned(shape: &[usize], sign: Sign, flag: Flag) -> Result ``` ##### Description Create a new plan with aligned vectors. ``` -------------------------------- ### Mutate exact-size chunks in reverse Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Uses rchunks_exact_mut to modify fixed-size chunks of a slice, starting from the end. ```rust let v = &mut [0, 0, 0, 0, 0]; let mut count = 1; for chunk in v.rchunks_exact_mut(2) { for elem in chunk.iter_mut() { *elem += count; } count += 1; } assert_eq!(v, &[0, 2, 2, 1, 1]); ``` -------------------------------- ### C2RPlan Implementation for Plan Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2RPlan.html Concrete implementation of C2RPlan for double-precision floats (f64) and complex numbers (c64). Specifies Real as f64 and Complex as Complex. ```rust impl C2RPlan for Plan { type Real = f64; type Complex = Complex; } ``` -------------------------------- ### R2RPlan64::new Source: https://docs.rs/fftw/latest/fftw/plan/type.R2RPlan64.html Creates a new R2RPlan64 instance for performing real-to-real transforms. ```APIDOC ## R2RPlan64::new ### Description Creates a new plan for real-to-real transforms with the specified shape, input/output buffers, transform kind, and flags. ### Parameters - **shape** (&[usize]) - Required - The dimensions of the transform. - **in_** (&mut [f64]) - Required - Mutable reference to the input buffer. - **out** (&mut [f64]) - Required - Mutable reference to the output buffer. - **kind** (R2RKind) - Required - The type of R2R transform to perform. - **flag** (Flag) - Required - Configuration flags for the FFTW planner. ### Response - **Result** - Returns a new R2RPlan64 instance or an error if the plan creation fails. ``` -------------------------------- ### Get mutable slice element or subslice Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Safely retrieves a mutable reference to an element or subslice by index or range. ```rust let x = &mut [0, 1, 2]; if let Some(elem) = x.get_mut(1) { *elem = 42; } assert_eq!(x, &[0, 42, 2]); ``` -------------------------------- ### R2RPlan::aligned Source: https://docs.rs/fftw/latest/fftw/plan/trait.R2RPlan.html Creates a new plan with aligned memory allocation. ```APIDOC ## fn aligned ### Description Creates a new plan with aligned vector allocation. ### Parameters - **shape** (&[usize]) - Required - The dimensions of the transform. - **kind** (R2RKind) - Required - The type of R2R transform. - **flag** (Flag) - Required - FFTW planning flags. ### Response - **Result** - Returns the new plan or an error. ``` -------------------------------- ### Get slice element or subslice Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Safely retrieves an element or subslice by index or range, returning None if out of bounds. ```rust let v = [10, 40, 30]; assert_eq!(Some(&40), v.get(1)); assert_eq!(Some(&[10, 40][..]), v.get(0..2)); assert_eq!(None, v.get(3)); assert_eq!(None, v.get(0..4)); ``` -------------------------------- ### rsplitn Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an iterator over subslices separated by elements that match a predicate, limited to n items, starting from the end. ```APIDOC ## pub fn rsplitn(&self, n: usize, pred: F) -> RSplitN<'_, T, F> ### Description Returns an iterator over subslices separated by elements that match `pred` limited to returning at most `n` items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice. ### Parameters - **n** (usize) - Required - The maximum number of items to return. - **pred** (FnMut(&T) -> bool) - Required - The predicate function used to identify split points. ``` -------------------------------- ### R2RPlan64::r2r Source: https://docs.rs/fftw/latest/fftw/plan/type.R2RPlan64.html Executes the real-to-real transform using the configured plan. ```APIDOC ## R2RPlan64::r2r ### Description Executes the real-to-real transform on the provided input and output buffers. ### Parameters - **in_** (&mut [f64]) - Required - Mutable reference to the input buffer. - **out** (&mut [f64]) - Required - Mutable reference to the output buffer. ### Response - **Result<()>** - Returns Ok(()) on success, or an error if the execution fails. ``` -------------------------------- ### Reverse split a slice into at most N parts Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a slice into subslices starting from the end, limited to at most n items. ```rust let v = [10, 40, 30, 20, 60, 50]; for group in v.rsplitn(2, |num| *num % 3 == 0) { println!("{group:?}"); } ``` -------------------------------- ### R2RPlan::r2r Source: https://docs.rs/fftw/latest/fftw/plan/trait.R2RPlan.html Executes the real-to-real transform using the created plan. ```APIDOC ## fn r2r ### Description Executes the real-to-real transform on the provided buffers. ### Parameters - **in_** (&mut [Self::Real]) - Required - Input buffer. - **out_** (&mut [Self::Real]) - Required - Output buffer. ### Response - **Result<()>** - Returns Ok(()) on success or an error. ``` -------------------------------- ### C2RPlan::new Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2RPlan.html Creates a new plan for a complex-to-real transformation. ```APIDOC ## fn new ### Description Creates a new plan for a complex-to-real transformation. ### Parameters - **shape** (&[usize]) - Required - The shape of the transformation. - **in_** (&mut [Self::Complex]) - Required - Input buffer for complex data. - **out** (&mut [Self::Real]) - Required - Output buffer for real data. - **flag** (Flag) - Required - FFTW planning flags. ### Response - **Result** - Returns the initialized plan or an error. ``` -------------------------------- ### Mutate slice chunks in reverse Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Uses rchunks_mut to modify elements within chunks of a slice, starting from the end. ```rust let v = &mut [0, 0, 0, 0, 0]; let mut count = 1; for chunk in v.rchunks_mut(2) { for elem in chunk.iter_mut() { *elem += count; } count += 1; } assert_eq!(v, &[3, 2, 2, 1, 1]); ``` -------------------------------- ### Get last chunk of slice Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an array reference to the last N items in the slice, or None if the slice is too short. ```rust let u = [10, 40, 30]; assert_eq!(Some(&[40, 30]), u.last_chunk::<2>()); let v: &[i32] = &[10]; assert_eq!(None, v.last_chunk::<2>()); let w: &[i32] = &[]; assert_eq!(Some(&[]), w.last_chunk::<0>()); ``` -------------------------------- ### FFTW Plan Struct Source: https://docs.rs/fftw/latest/fftw/plan/index.html Documentation for the 'Plan' struct, which serves as a typed wrapper for `fftw_plan`. ```APIDOC ## Struct: Plan ### Description Typed wrapper of `fftw_plan`. ### Fields (No specific fields are detailed in the provided text.) ### Methods (No specific methods are detailed in the provided text.) ``` -------------------------------- ### C2RPlan Implementation for Plan Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2RPlan.html Concrete implementation of C2RPlan for single-precision floats (f32) and complex numbers (c32). Specifies Real as f32 and Complex as Complex. ```rust impl C2RPlan for Plan { type Real = f32; type Complex = Complex; } ``` -------------------------------- ### From Conversions Source: https://docs.rs/fftw/latest/fftw/types/type.c64.html Shows how to convert other types into Complex numbers. ```APIDOC ## From Conversions for Complex ### Description Implements conversions from other types into `Complex`. ### Methods - `from(re: &T) -> Complex`: Converts from a reference to type `T`. - `from(re: T) -> Complex`: Converts from type `T`. ### Constraints - `T: Clone + Num` ``` -------------------------------- ### rsplitn_mut Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an iterator over mutable subslices separated by elements that match a predicate, limited to n items, starting from the end. ```APIDOC ## pub fn rsplitn_mut(&mut self, n: usize, pred: F) -> RSplitNMut<'_, T, F> ### Description Returns an iterator over mutable subslices separated by elements that match `pred` limited to returning at most `n` items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice. ### Parameters - **n** (usize) - Required - The maximum number of items to return. - **pred** (FnMut(&T) -> bool) - Required - The predicate function used to identify split points. ``` -------------------------------- ### Partition Slice by Key Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html This nightly-only experimental API partitions a slice by moving consecutive elements that resolve to the same key to the end. It returns two slices: one with unique elements and one with duplicates. ```rust #![feature(slice_partition_dedup)] let mut slice = [10, 20, 21, 30, 30, 20, 11, 13]; let (dedup, duplicates) = slice.partition_dedup_by_key(|i| *i / 10); assert_eq!(dedup, [10, 20, 30, 20, 11]); assert_eq!(duplicates, [21, 30, 13]); ``` -------------------------------- ### Create New R2CPlan Source: https://docs.rs/fftw/latest/fftw/plan/type.R2CPlan64.html Creates a new real-to-complex plan. Requires specifying the shape of the transform, mutable slices for input real data and output complex data, and a planning flag. Returns a Result containing the plan or an error. ```rust fn new( shape: &[usize], in_: &mut [Self::Real], out: &mut [Self::Complex], flag: Flag, ) -> Result ``` -------------------------------- ### pub fn rchunks_exact Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice, omitting the remainder. ```APIDOC ## rchunks_exact ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. If `chunk_size` does not divide the length of the slice, the remainder is omitted. ### Parameters - **chunk_size** (usize) - Required - The number of elements per chunk. Panics if zero. ``` -------------------------------- ### Implement Plan Specification Traits Source: https://docs.rs/fftw/latest/src/fftw/plan.rs.html Macro to implement validation, destruction, and printing for FFTW plan types. ```rust impl_plan_spec!(Plan64; fftw_destroy_plan, fftw_print_plan); impl_plan_spec!(Plan32; fftwf_destroy_plan, fftwf_print_plan); ``` -------------------------------- ### Iterate over slice chunks in reverse Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Demonstrates using rchunks to iterate over a slice in chunks of a specified size, starting from the end. ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.rchunks(2); assert_eq!(iter.next().unwrap(), &['e', 'm']); assert_eq!(iter.next().unwrap(), &['o', 'r']); assert_eq!(iter.next().unwrap(), &['l']); assert!(iter.next().is_none()); ``` -------------------------------- ### as_rchunks Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a slice into `N`-element arrays starting from the end, and a remainder slice. The remainder contains the initial elements. ```APIDOC ## as_rchunks ### Description Splits the slice into a slice of `N`-element arrays, starting at the end of the slice, and a remainder slice with length strictly less than `N`. The remainder is meaningful in the division sense. Given `let (remainder, chunks) = slice.as_rchunks()`, then: * `remainder.len()` equals `slice.len() % N`, * `chunks.len()` equals `slice.len() / N`, and * `slice.len()` equals `chunks.len() * N + remainder.len()`. You can flatten the chunks back into a slice-of-`T` with `as_flattened`. ### Method `fn as_rchunks(&self) -> (&[T], &[[T; N]])` ### Panics Panics if `N` is zero. Note that this check is against a const generic parameter, not a runtime value, and thus a particular monomorphization will either always panic or it will never panic. ### Examples ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let (remainder, chunks) = slice.as_rchunks(); assert_eq!(remainder, &['l']); assert_eq!(chunks, &[['o', 'r'], ['e', 'm']]); ``` ``` -------------------------------- ### Implement R2R FFTW Plans Source: https://docs.rs/fftw/latest/src/fftw/plan.rs.html Macro to generate R2R plan implementations for specific floating-point types. ```rust impl_r2r!(f64, Plan64; fftw_plan_r2r, fftw_execute_r2r); impl_r2r!(f32, Plan32; fftwf_plan_r2r, fftwf_execute_r2r); ``` -------------------------------- ### Create New Complex-to-Complex Plan Source: https://docs.rs/fftw/latest/fftw/plan/type.C2CPlan32.html Creates a new plan for executing a complex-to-complex FFT. Requires mutable slices for input and output, along with sign, flag, and shape specifications. ```rust fn new( shape: &[usize], in_: &mut [Self::Complex], out: &mut [Self::Complex], sign: Sign, flag: Flag, ) -> Result ``` -------------------------------- ### Create Aligned Complex-to-Complex Plan Source: https://docs.rs/fftw/latest/fftw/plan/type.C2CPlan32.html Creates a new plan for a complex-to-complex FFT with aligned vector support. This can improve performance on certain architectures. Requires shape, sign, and flag. ```rust fn aligned(shape: &[usize], sign: Sign, flag: Flag) -> Result ``` -------------------------------- ### Mutably Iterate Over Slice Elements in Rust Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Use `iter_mut()` to get a mutable iterator over slice elements. This allows modification of each item. ```rust let x = &mut [1, 2, 4]; for elem in x.iter_mut() { *elem += 2; } assert_eq!(x, &[3, 4, 6]); ``` -------------------------------- ### Get unchecked slice element Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Retrieves an element or subslice without bounds checking. Calling with an out-of-bounds index is undefined behavior. ```rust let x = &[1, 2, 4]; unsafe { assert_eq!(x.get_unchecked(1), &2); } ``` -------------------------------- ### Basic align_to Usage Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Demonstrates basic usage of `align_to` to split a byte slice into a prefix, a slice of `u16`, and a suffix. This method is unsafe and requires careful handling of memory alignment. ```rust unsafe { let bytes: [u8; 7] = [1, 2, 3, 4, 5, 6, 7]; let (prefix, shorts, suffix) = bytes.align_to::(); // less_efficient_algorithm_for_bytes(prefix); // more_efficient_algorithm_for_aligned_shorts(shorts); // less_efficient_algorithm_for_bytes(suffix); } ``` -------------------------------- ### Mutably reverse split a slice into at most N parts Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Splits a slice into mutable subslices starting from the end, limited to at most n items. ```rust let mut s = [10, 40, 30, 20, 60, 50]; for group in s.rsplitn_mut(2, |num| *num % 3 == 0) { group[0] = 1; } assert_eq!(s, [1, 40, 30, 20, 60, 1]); ``` -------------------------------- ### C2CPlan Implementations Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2CPlan.html Details on the implementations of the C2CPlan trait for different plan types. ```APIDOC ### Implementors #### impl C2CPlan for Plan ##### type Complex = Complex #### impl C2CPlan for Plan ##### type Complex = Complex ``` -------------------------------- ### pub fn rchunks_mut Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Returns an iterator over chunk_size elements of the slice at a time, starting at the end of the slice, providing mutable access. ```APIDOC ## rchunks_mut ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. The chunks are mutable slices and do not overlap. ### Parameters - **chunk_size** (usize) - Required - The number of elements per chunk. Panics if zero. ``` -------------------------------- ### C2RPlan aligned Method Source: https://docs.rs/fftw/latest/fftw/plan/trait.C2RPlan.html Provides a default implementation for creating a new plan with aligned vectors. Uses the shape and transformation flags. ```rust fn aligned(shape: &[usize], flag: Flag) -> Result { ... } ``` -------------------------------- ### Slice Pointer Range Access Source: https://docs.rs/fftw/latest/fftw/array/struct.AlignedVec.html Get a half-open range of pointers spanning the slice. Useful for checking if a pointer belongs to the slice range. ```rust let a = [1, 2, 3]; let x = &a[1] as *const _; let y = &5 as *const _; assert!(a.as_ptr_range().contains(&x)); assert!(!a.as_ptr_range().contains(&y)); ``` -------------------------------- ### Create New R2R Plan Source: https://docs.rs/fftw/latest/fftw/plan/type.R2RPlan64.html Use this function to create a new real-to-real plan. Ensure input and output slices are mutable and correctly sized according to the shape. ```rust fn new( shape: &[usize], in_: &mut [Self::Real], out: &mut [Self::Real], kind: R2RKind, flag: Flag, ) -> Result ```