paddle.fft. fftshift ( x, axes=None, name=None ) [source]

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

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

  • n (int) – Dimension inputed.

  • axes (int|tuple, optional) – The axis on which to move. The default is none, which moves all axes. Default is None.

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.


Tensor. The shifted tensor.


import numpy as np
import paddle

x = np.array([3, 1, 2, 2, 3], dtype=float)
n = x.size
fftfreq_xp = paddle.fft.fftfreq(n, d=0.3)
res = paddle.fft.fftshift(fftfreq_xp).numpy()
#  [-1.3333334 -0.6666667  0.         0.6666667  1.3333334]