Skip to main content

fftshift

Function fftshift 

Source
pub fn fftshift<'a>(
    a: impl AsRef<Array>,
    axes: impl IntoOption<&'a [i32]>,
) -> Result<Array>
Expand description

Shift the zero-frequency component to the center of the spectrum.

This function swaps half-spaces for all axes listed (defaults to all). Note that y[0] is the Nyquist component only if len(x) is even.

§Params

  • a: The input array.
  • axes: Axes over which to shift. The default is None which shifts all axes.

§Example

use mlx_rs::{Array, fft::*};

let a = Array::from_slice(&[0.0f32, 1.0, 2.0, 3.0, 4.0, -4.0, -3.0, -2.0, -1.0], &[9]);
let shifted = fftshift(&a, None).unwrap();
// shifted contains: [-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0]