max_shift_invariant_level

Function max_shift_invariant_level 

Source
pub fn max_shift_invariant_level(
    signal_length: usize,
    filter_length: usize,
) -> usize
Expand description

Calculate the maximum decomposition level for shift-invariant transforms (MODWT/SWT)

For shift-invariant transforms that don’t downsample, the maximum level is constrained by the filter dilation: 2^J * (L-1) < N where J is the level, L is the filter length, and N is the signal length.

This function is used by both MODWT and SWT since they have identical constraints.

§Arguments

  • signal_length - Length of the input signal
  • filter_length - Length of the wavelet filter

§Returns

Maximum valid decomposition level

§Example

use iron_wave::transform::max_shift_invariant_level;

// For a signal of length 100 and filter of length 4:
// Level 0: 2^0 * 3 = 3 < 100 ✓
// Level 1: 2^1 * 3 = 6 < 100 ✓
// Level 2: 2^2 * 3 = 12 < 100 ✓
// Level 3: 2^3 * 3 = 24 < 100 ✓
// Level 4: 2^4 * 3 = 48 < 100 ✓
// Level 5: 2^5 * 3 = 96 < 100 ✓
// Level 6: 2^6 * 3 = 192 > 100 ✗
assert_eq!(max_shift_invariant_level(100, 4), 5);