fftn¶
- paddle.fft. fftn ( x, s=None, axes=None, norm='backward', name=None ) [source]
-
Compute the N-D discrete Fourier Transform.
This function calculates the n-D discrete Fourier transform on any number of axes in the M-D array by fast Fourier transform (FFT).
- Parameters
-
x (Tensor) – The input data. It’s a Tensor type. It’s a complex.
s (sequence of ints, optional) – Shape (length of each transformed axis) of the output (
s[0]
refers to axis 0,s[1]
to axis 1, etc.). This corresponds ton
forfft(x, n)
. Along any axis, if the given shape is smaller than that of the input, the input is cropped. If it is larger, the input is padded with zeros. if s is not given, the shape of the input along the axes specified by axes is used.axes (sequence of ints, optional) – Axes used to calculate FFT. If not given, the last
len(s)
axes are used, or all axes if s is also not specified.norm (str, optional) – Indicates which direction to scale the forward or backward transform pair and what normalization factor to use. The parameter value must be one of “forward” or “backward” or “ortho”. Default is “backward”, meaning no normalization on the forward transforms and scaling by
1/n
on the ifft. “forward” instead applies the1/n
factor on the forward transform. Fornorm="ortho"
, both directions are scaled by1/sqrt(n)
.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.
- Returns
-
complex tensor. The truncated or zero-padded input, transformed along the axes indicated by axes, or by a combination of s and x, as explained in the parameters section above.
Examples
>>> import paddle >>> arr = paddle.arange(4, dtype="float64") >>> x = paddle.meshgrid(arr, arr, arr)[1] >>> fftn_xp = paddle.fft.fftn(x, axes=(1, 2)) >>> print(fftn_xp) Tensor(shape=[4, 4, 4], dtype=complex128, place=Place(cpu), stop_gradient=True, [[[(24+0j), 0j, 0j, -0j], [(-8+8j), 0j, 0j, -0j], [(-8+0j), 0j, 0j, -0j], [(-8-8j), 0j, 0j, -0j]], [[(24+0j), 0j, 0j, -0j], [(-8+8j), 0j, 0j, -0j], [(-8+0j), 0j, 0j, -0j], [(-8-8j), 0j, 0j, -0j]], [[(24+0j), 0j, 0j, -0j], [(-8+8j), 0j, 0j, -0j], [(-8+0j), 0j, 0j, -0j], [(-8-8j), 0j, 0j, -0j]], [[(24+0j), 0j, 0j, -0j], [(-8+8j), 0j, 0j, -0j], [(-8+0j), 0j, 0j, -0j], [(-8-8j), 0j, 0j, -0j]]])