rfft2

Function rfft2 

Source
pub fn rfft2<T>(
    x: &ArrayView2<'_, T>,
    shape: Option<(usize, usize)>,
    _axes: Option<(usize, usize)>,
    _norm: Option<&str>,
) -> FFTResult<Array2<Complex64>>
where T: NumCast + Copy + Debug + 'static,
Expand description

Compute the 2-dimensional discrete Fourier Transform for real input.

§Arguments

  • x - Input real-valued 2D array
  • shape - Shape of the transformed array (optional)

§Returns

  • The 2-dimensional Fourier transform of the real input array

§Examples

use scirs2_fft::rfft2;
use scirs2_core::ndarray::Array2;

// Create a 2x2 array
let signal = Array2::from_shape_vec((2, 2), vec![1.0, 2.0, 3.0, 4.0]).unwrap();

// Compute 2D RFFT with all parameters
// None for shape (default shape)
// None for axes (default axes)
// None for normalization (default "backward" normalization)
let spectrum = rfft2(&signal.view(), None, None, None).unwrap();

// For real input, the first dimension of the output has size (n1//2 + 1)
assert_eq!(spectrum.dim(), (signal.dim().0 / 2 + 1, signal.dim().1));

// Check the DC component (sum of all elements)
assert_eq!(spectrum[[0, 0]].re, 10.0); // 1.0 + 2.0 + 3.0 + 4.0 = 10.0