pub fn reconstruct_spectrum(
sparse_result: &SparseFFTResult,
n: usize,
) -> FFTResult<Vec<Complex64>>
Expand description
Reconstruct the full spectrum from sparse FFT result
§Arguments
sparse_result
- The sparse FFT resultn
- Length of the full spectrum
§Returns
- Full spectrum
§Examples
use scirs2_fft::sparse_fft::{sparse_fft, reconstruct_spectrum};
// Generate a sparse signal
let n = 64;
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() + 0.5 * (7.0 * t).sin();
}
// Compute sparse FFT with k=4
let sparse_result = sparse_fft(&signal, 4, None, None).unwrap();
// Reconstruct full spectrum
let full_spectrum = reconstruct_spectrum(&sparse_result, n).unwrap();
// The reconstructed spectrum should have length n
assert_eq!(full_spectrum.len(), n);