Skip to main content

fftshift

Function fftshift 

Source
pub fn fftshift<T: Copy>(x: &[T]) -> Vec<T>
Expand description

Swap the two halves of a spectrum so that the zero frequency is in the middle (numpy.fft.fftshift): the bin (i + ⌊N/2⌋) mod N moves to i.

§Examples

use comnum_math::fft::fftshift;
assert_eq!(fftshift(&[0, 1, 2, -2, -1]), [-2, -1, 0, 1, 2]);
assert_eq!(fftshift(&[0, 1, -2, -1]), [-2, -1, 0, 1]);