pub fn fftshift2(
x: &ArrayBase<OwnedRepr<Complex<f64>>, Dim<[usize; 2]>>,
) -> ArrayBase<OwnedRepr<Complex<f64>>, Dim<[usize; 2]>>Expand description
Shift the zero-frequency component to the centre of a 2-D complex array.
For a 2-D FFT output of shape (M, N) the DC component is at [0, 0].
fftshift2 moves it to the centre position [M/2, N/2] (integer division),
which is the natural representation for visualisation.
§Examples
use scirs2_fft::ndim::fftshift2;
use scirs2_core::ndarray::Array2;
use scirs2_core::numeric::Complex64;
// 4×4 array where position [0,0] has value 1 (DC component)
let mut data = Array2::<Complex64>::zeros((4, 4));
data[[0, 0]] = Complex64::new(1.0, 0.0);
let shifted = fftshift2(&data);
// After shift the DC component is at [2, 2]
assert!((shifted[[2, 2]].re - 1.0).abs() < 1e-12);