ifftn

Function ifftn 

Source
pub fn ifftn<T>(
    input: &ArrayD<T>,
    shape: Option<Vec<usize>>,
    axes: Option<Vec<usize>>,
    norm: Option<&str>,
    _overwrite_x: Option<bool>,
    _workers: Option<usize>,
) -> FFTResult<ArrayD<Complex64>>
where T: NumCast + Copy + Debug + 'static,
Expand description

Compute the inverse N-dimensional Fast Fourier Transform

§Arguments

  • input - Input N-dimensional array
  • shape - Shape of the output (optional)
  • axes - Axes along which to compute the inverse FFT (optional)
  • norm - Normalization mode: “backward”, “ortho”, or “forward” (optional)
  • overwrite_x - Whether to overwrite the input array (optional)
  • workers - Number of worker threads to use (optional)

§Returns

An N-dimensional array of complex values representing the inverse FFT result

§Examples

use scirs2_fft::{fftn, ifftn};
use scirs2_core::ndarray::{Array, IxDyn};
use scirs2_core::numeric::Complex64;

// Create a 3D array
let mut data = Array::zeros(IxDyn(&[2, 2, 2]));
data[[0, 0, 0]] = 1.0;
data[[1, 1, 1]] = 1.0;

// Compute the N-dimensional FFT
let spectrum = fftn(&data, None, None, None, None, None).unwrap();

// Compute the inverse N-dimensional FFT
let result = ifftn(&spectrum, None, None, None, None, None).unwrap();

// Check if the original data is recovered
for i in 0..2 {
    for j in 0..2 {
        for k in 0..2 {
            let expected = if (i == 0 && j == 0 && k == 0) || (i == 1 && j == 1 && k == 1) {
                1.0
            } else {
                0.0
            };
            assert!((result[[i, j, k]].re - expected).abs() < 1e-10);
            assert!(result[[i, j, k]].im.abs() < 1e-10);
        }
    }
}