hfft

Function hfft 

Source
pub fn hfft<T>(
    x: &[T],
    n: Option<usize>,
    norm: Option<&str>,
) -> FFTResult<Vec<f64>>
where T: NumCast + Copy + Debug + 'static,
Expand description

Compute the 1-dimensional discrete Fourier Transform for a Hermitian-symmetric input.

This function computes the FFT of a Hermitian-symmetric complex array, resulting in a real-valued output. A Hermitian-symmetric array satisfies a[i] = conj(a[-i]) for all indices i.

§Arguments

  • x - Input complex-valued array with Hermitian symmetry
  • n - Length of the transformed axis (optional)
  • norm - Normalization mode (optional, default is “backward”):
    • “backward”: No normalization on forward transforms, 1/n on inverse
    • “forward”: 1/n on forward transforms, no normalization on inverse
    • “ortho”: 1/sqrt(n) on both forward and inverse transforms

§Returns

  • The real-valued Fourier transform of the Hermitian-symmetric input array

§Examples

use num_complex::Complex64;
use scirs2_fft::hfft;

// Create a simple Hermitian-symmetric array (DC component is real)
let x = vec![
    Complex64::new(1.0, 0.0),  // DC component (real)
    Complex64::new(2.0, 1.0),  // Positive frequency
    Complex64::new(2.0, -1.0), // Negative frequency (conjugate of above)
];

// Compute the HFFT
let result = hfft(&x, None, None).unwrap();

// The result should be real-valued
assert!(result.len() == 3);
// Check that the result is real (imaginary parts are negligible)
for &val in &result {
    assert!(val.is_finite());
}