cwt

Function cwt 

pub fn cwt<T>(
    signal: &Signal<T>,
    wavelet: &dyn ContinuousWavelet,
    scales: &[f64],
    sampling_freq: f64,
) -> Result<CWTResult<T>>
Expand description

Compute Continuous Wavelet Transform (direct convolution)

This is the reference implementation using direct time-domain convolution. For better performance on larger signals, use cwt_fft instead.

§Complexity

O(N² × M) where N is signal length and M is number of scales.

§Valid scale range

For meaningful coefficients keep scale ∈ [~ω₀/π, N/16] — roughly [2, N/16] for the default Morlet (ω₀ = 6). Outside this band the output is dominated by discretisation, not by the transform:

  • Small scales (ω₀/scale ≳ π, i.e. scale ≲ ω₀/π ≈ 1.9 for ω₀ = 6): this direct path time-samples the wavelet, so an oscillation near the Nyquist limit is under-resolved. Prefer cwt_fft, which uses the wavelet’s exact analytic Fourier transform and stays accurate to smaller scales.
  • Large scales (scale ≳ N/8): the wavelet support approaches the signal length, so the (truncated-linear) boundary handling dominates; the coefficients there are off-band and tiny — boundary artefacts, not signal.

Within the valid band cwt and cwt_fft are the same transform via two algorithms and agree to ~1e-9 (mid-band to machine precision). They diverge only at the extremes above, for the reasons given — this is the methods’ accuracy envelope, not a normalisation difference. See tests/cwt_fft_accumulation.rs.