Rate This Document
Findability
Accuracy
Completeness
Readability

fft.fftn

Description

Compute the N-dimensional discrete Fourier Transform.

Mandatory Input Parameters

Parameter

Type

Description

a

array_like

Input array, which can be a complex number

Optional Input Parameters

Parameter

Type

Default Value

Description

s

sequence of ints

None

Output shape (length of each transformed axis. s[0] refers to axis 0, s[1] to axis 1, etc.). This corresponds to n for fft(x, n). Along each 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

-1

Axis over which to compute the FFT. If not given, the last n axes are used.

norm

{"backward", "ortho", "forward"}, optional

backward

Normalization mode (see numpy.fft). It indicates which direction of the forward/backward pair of transforms is scaled and with what normalization factor.

Return Value

Type

Description

ndarray

The truncated or zero-padded input, transformed along the axes specified by axes, or the last n axes if axes is not specified.

Examples

>>> import numpy as np
>>> a = np.mgrid[:3, :3, :3][0]
>>> a
array([[[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

       [[1, 1, 1],
        [1, 1, 1],
        [1, 1, 1]],

       [[2, 2, 2],
        [2, 2, 2],
        [2, 2, 2]]])
>>> 
>>> np.fft.fftn(a)
array([[[ 27. +0.j        ,   0. +0.j        ,   0. +0.j        ],
        [  0. +0.j        ,   0. +0.j        ,   0. +0.j        ],
        [  0. +0.j        ,   0. +0.j        ,   0. +0.j        ]],

       [[-13.5+7.79422863j,   0. +0.j        ,   0. +0.j        ],
        [  0. +0.j        ,   0. +0.j        ,   0. +0.j        ],
        [  0. +0.j        ,   0. +0.j        ,   0. +0.j        ]],

       [[-13.5-7.79422863j,   0. +0.j        ,   0. +0.j        ],
        [  0. +0.j        ,   0. +0.j        ,   0. +0.j        ],
        [  0. +0.j        ,   0. +0.j        ,   0. +0.j        ]]])
>>> 
>>> np.fft.fftn(a, (2,2), axes=(0,1))
array([[[ 2.+0.j,  2.+0.j,  2.+0.j],
        [ 0.+0.j,  0.+0.j,  0.+0.j]],

       [[-2.+0.j, -2.+0.j, -2.+0.j],
        [ 0.+0.j,  0.+0.j,  0.+0.j]]])
>>>