rfftn¶
- rfftn(x: array, /, *, s: Sequence[int] | None = None, axes: Sequence[int] | None = None, norm: Literal['backward', 'ortho', 'forward'] = 'backward') array ¶
Computes the n-dimensional discrete Fourier transform for real-valued input.
Note
Applying the n-dimensional inverse discrete Fourier transform for real-valued input to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e.,
irfftn(rfftn(x)) == x
), provided that the transform and inverse transform are performed with the same arguments (axes and normalization mode) and consistent sizes.- Parameters:
x (array) – input array. Must have a real-valued floating-point data type.
s (Optional[Sequence[int]]) –
number of elements over which to compute the transform along axes (dimensions) specified by
axes
. Leti
be the index of then
-th axis specified byaxes
(i.e.,i = axes[n]
) andM[i]
be the size of the input array along axisi
. Whens
isNone
, the function must sets
equal to a sequence of integers such thats[i]
equalsM[i]
for alli
.If
s[i]
is greater thanM[i]
, axisi
must be zero-padded to sizes[i]
.If
s[i]
is less thanM[i]
, axisi
must be trimmed to sizes[i]
.If
s[i]
equalsM[i]
or-1
, all elements along axisi
must be used when computing the transform.
If
s
is notNone
,axes
must not beNone
. Default:None
.axes (Optional[Sequence[int]]) –
axes (dimensions) over which to compute the transform. A valid axis in
axes
must be an integer on the interval[-N, N)
, whereN
is the rank (number of dimensions) ofx
. If an axis is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where-1
refers to the last dimension).If
s
is provided, the correspondingaxes
to be transformed must also be provided. Ifaxes
isNone
, the function must compute the transform over all axes. Default:None
.If
axes
contains two or more entries which resolve to the same axis (i.e., resolved axes are not unique), the behavior is unspecified and thus implementation-defined.norm (Literal['backward', 'ortho', 'forward']) –
normalization mode. Should be one of the following modes:
'backward'
: no normalization.'ortho'
: normalize by1/sqrt(n)
(i.e., make the FFT orthonormal).'forward'
: normalize by1/n
.
where
n = prod(s)
, the logical FFT size.Default:
'backward'
.
- Returns:
out (array) – an array transformed along the axes (dimension) specified by
axes
. The returned array must have a complex floating-point data type whose precision matches the precision ofx
(e.g., ifx
isfloat64
, then the returned array must have acomplex128
data type). The returned array must have the same shape asx
, except for the last transformed axis which must have sizes[-1]//2 + 1
and the remaining transformed axes which must have sizes[i]
.
Notes
New in version 2022.12.