reconstruct_high_resolution

Function reconstruct_high_resolution 

Source
pub fn reconstruct_high_resolution(
    sparse_result: &SparseFFTResult,
    original_length: usize,
    target_length: usize,
) -> FFTResult<Vec<Complex64>>
Expand description

Reconstructs a signal with enhanced frequency resolution by zero padding

This method allows reconstructing a signal with higher frequency resolution by zero-padding the sparse spectrum before performing the inverse FFT.

§Arguments

  • sparse_result - The sparse FFT result containing frequency components
  • original_length - The original length of the signal
  • target_length - The desired length after zero padding (must be >= original_length)

§Returns

  • The reconstructed signal with enhanced frequency resolution

§Examples

use scirs2_fft::sparse_fft::{sparse_fft, reconstruct_high_resolution};

// Generate a sparse signal
let n = 32;
let mut signal = vec![0.0; n];
for i in 0..n {
    let t = 2.0 * std::f64::consts::PI * (i as f64) / (n as f64);
    signal[i] = 1.0 * (3.0 * t).sin();
}

// Compute sparse FFT
let sparse_result = sparse_fft(&signal, 2, None, None).unwrap();

// Reconstruct with higher resolution (2x the original length)
let high_res = reconstruct_high_resolution(&sparse_result, n, 2 * n).unwrap();

// The high-resolution signal should have the target length
assert_eq!(high_res.len(), 2 * n);