Skip to main content

wpd

Function wpd 

Source
pub fn wpd(
    signal: &[f64],
    wavelet: Wavelet,
    max_level: usize,
) -> Result<WaveletPacketTree, FFTError>
Expand description

Perform a full wavelet packet decomposition up to max_level.

Every node (approximation and detail) at every level is recursively decomposed, producing a complete binary tree with 2^(max_level+1) - 1 nodes.

§Arguments

  • signal – Real-valued input signal.
  • wavelet – Wavelet to use (determines analysis filters).
  • max_level – Maximum decomposition depth. The root is level 0.

§Errors

Returns FFTError::ValueError if signal is empty or max_level == 0.

§Example

use scirs2_fft::wavelet_packets::{wpd, Wavelet};

let signal: Vec<f64> = (0..64).map(|i| (i as f64 * 0.1).sin()).collect();
let tree = wpd(&signal, Wavelet::Db4, 3).expect("decomposition failed");
// Tree has nodes at levels 0 through 3
assert!(tree.get(0, 0).is_some());
assert!(tree.get(3, 7).is_some());