pub struct WaveletDictionary { /* private fields */ }Expand description
Wavelet-based dictionary for Matching Pursuit
Pre-computes and stores all dictionary atoms for fast matching. Uses parallel generation and optimized memory layout for performance.
§Invariants
- Unit Norm: All atoms have L2 norm = 1 (normalized during generation)
- Completeness: All valid (wavelet, scale, position) combinations are pre-generated
- Fast Lookup: O(1) atom access via HashMap indexing
Implementations§
Source§impl WaveletDictionary
impl WaveletDictionary
Sourcepub const MAX_SIGNAL_LENGTH: usize = 4_096usize
pub const MAX_SIGNAL_LENGTH: usize = 4_096usize
Maximum signal length for pre-computed dictionary
Sourcepub fn new(
wavelets: Vec<Box<dyn Wavelet>>,
max_scale: usize,
signal_length: usize,
) -> Result<Self>
pub fn new( wavelets: Vec<Box<dyn Wavelet>>, max_scale: usize, signal_length: usize, ) -> Result<Self>
Create a new wavelet dictionary with pre-computed atoms
Generates and stores all atoms in parallel for fast matching.
§Arguments
wavelets- Collection of wavelets to use for atom generationmax_scale- Maximum decomposition scalesignal_length- Length of signals this dictionary will process (max 4096)
§Returns
New WaveletDictionary instance with pre-computed atoms
§Errors
Returns error if:
- No wavelets provided
- Signal length is 0 or > 4096
- max_scale is 0 (no atoms would be generated)
- max_scale is too large (would result in 0 positions at highest scale)
- Atom generation fails (includes wavelet index, scale, and position in error message)
- Any generated atom has near-zero norm (< 1e-10), violating the unit-norm invariant
Sourcepub fn num_wavelets(&self) -> usize
pub fn num_wavelets(&self) -> usize
Get number of wavelets in dictionary
Trait Implementations§
Source§impl Dictionary<f64> for WaveletDictionary
impl Dictionary<f64> for WaveletDictionary
Source§fn get_atom(&self, index: &AtomIndex) -> Result<Signal<f64>>
fn get_atom(&self, index: &AtomIndex) -> Result<Signal<f64>>
Get the atom at the specified index Read more
Source§fn get_atom_data(&self, index: &AtomIndex) -> Result<&[f64]>
fn get_atom_data(&self, index: &AtomIndex) -> Result<&[f64]>
Get read-only access to atom data without cloning Read more
Source§fn find_best_match(&self, signal: &Signal<f64>) -> Result<(AtomIndex, f64)>
fn find_best_match(&self, signal: &Signal<f64>) -> Result<(AtomIndex, f64)>
Find the atom that best matches the given signal Read more
Source§fn signal_length(&self) -> usize
fn signal_length(&self) -> usize
Signal length that this dictionary supports
Auto Trait Implementations§
impl Freeze for WaveletDictionary
impl RefUnwindSafe for WaveletDictionary
impl Send for WaveletDictionary
impl Sync for WaveletDictionary
impl Unpin for WaveletDictionary
impl UnwindSafe for WaveletDictionary
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
Mutably borrows from an owned value. Read more
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>
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 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>
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