fft

Function fft 

Source
pub fn fft<T>(input: &[T], n: Option<usize>) -> FFTResult<Vec<Complex64>>
where T: NumCast + Copy + Debug + 'static,
Expand description

Compute the 1-dimensional Fast Fourier Transform

§Arguments

  • input - Input data array
  • n - Length of the output (optional)

§Returns

A vector of complex values representing the FFT result

§Examples

use scirs2_fft::fft;
use scirs2_core::numeric::Complex64;

// Generate a simple signal
let signal = vec![1.0, 2.0, 3.0, 4.0];

// Compute the FFT
let spectrum = fft(&signal, None).unwrap();

// The DC component should be the sum of the input
assert!((spectrum[0].re - 10.0).abs() < 1e-10);
assert!(spectrum[0].im.abs() < 1e-10);