Function max_decomposition_level_with_boundary
pub fn max_decomposition_level_with_boundary(
signal_length: usize,
filter_length: usize,
boundary: BoundaryMode,
) -> usizeExpand description
Boundary-aware variant of max_decomposition_level.
Simulates the per-level output length using the same rule the DWT dispatcher applies:
BoundaryMode::Periodic:M = ⌈N / 2⌉BoundaryMode::Symmetric/Zero/Constant: PyWavelets-canonicalM = ⌊(N + L − 1) / 2⌋, whereLisfilter_length.
Returns the largest level J such that the approximation at level J
is still ≥ filter_length (i.e. there’s room for one more level after
the requested decomposition). Matches the conservative -1 convention of
max_decomposition_level so callers that pass the result to
crate::transform::dwt::dwt_multilevel get the same guarantees.
§Examples
use ferro_wave::transform::{max_decomposition_level_with_boundary, BoundaryMode};
// Length-5 Haar Periodic: 5 → 3 → 2 → 1. Two levels keep the
// approximation ≥ filter length 2; max_decomposition_level itself
// returns only 1 because it floor-halves (5 → 2 → 1).
assert_eq!(
max_decomposition_level_with_boundary(5, 2, BoundaryMode::Periodic),
2,
);
// Length-7 Db2 Symmetric: 7 → 5 → 4 → 3. Two levels are reachable
// before the approximation drops below filter length 4.
assert_eq!(
max_decomposition_level_with_boundary(7, 4, BoundaryMode::Symmetric),
2,
);
// Standard power-of-two case is unchanged from the boundary-agnostic
// function: 1024 → 512 → … → 2 → 1, max level = 9.
assert_eq!(
max_decomposition_level_with_boundary(1024, 2, BoundaryMode::Periodic),
9,
);