bundles / scipy latest / scipy / fft / _basic / irfftn
_Function
scipy.fft._basic:irfftn
source: /scipy/fft/_basic.py :1198
Signature
def irfftn ( x , s = None , axes = None , norm = None , overwrite_x = False , workers = None , * , plan = None ) Summary
Computes the inverse of rfftn
Extended Summary
This function computes the inverse of the N-D discrete Fourier Transform for real input over any number of axes in an M-D array by means of the Fast Fourier Transform (FFT). In other words, irfftn(rfftn(x), x.shape) == x to within numerical accuracy. (The a.shape is necessary like len(a) is for irfft, and for the same reason.)
The input should be ordered in the same way as is returned by rfftn, i.e., as for irfft for the final transformation axis, and as for ifftn along all the other axes.
Parameters
x: array_likeInput array.
s: sequence of ints, optionalShape (length of each transformed axis) of the output (
s[0]refers to axis 0,s[1]to axis 1, etc.).sis also the number of input points used along this axis, except for the last axis, wheres[-1]//2+1points of the input are used. Along any axis, if the shape indicated bysis smaller than that of the input, the input is cropped. If it is larger, the input is padded with zeros. Ifsis not given, the shape of the input along the axes specified by axes is used. Except for the last axis which is taken to be2*(m-1), wheremis the length of the input along that axis.axes: sequence of ints, optionalAxes over which to compute the inverse FFT. If not given, the last
len(s)axes are used, or all axes ifsis also not specified.norm: {"backward", "ortho", "forward"}, optionalNormalization mode (see fft). Default is "backward".
overwrite_x: bool, optionalIf True, the contents of
xcan be destroyed; the default is False. See fft for more details.workers: int, optionalMaximum number of workers to use for parallel computation. If negative, the value wraps around from
os.cpu_count(). See fft for more details.plan: object, optionalThis argument is reserved for passing in a precomputed plan provided by downstream FFT vendors. It is currently not used in SciPy.
Returns
out: ndarrayThe truncated or zero-padded input, transformed along the axes indicated by
axes, or by a combination ofsorx, as explained in the parameters section above. The length of each transformed axis is as given by the corresponding element ofs, or the length of the input in every axis except for the last one ifsis not given. In the final transformed axis the length of the output whensis not given is2*(m-1), wheremis the length of the final transformed axis of the input. To get an odd number of output points in the final axis,smust be specified.
Raises
: ValueErrorIf
sandaxeshave different length.: IndexErrorIf an element of
axesis larger than the number of axes ofx.
Notes
See fft for definitions and conventions used.
See rfft for definitions and conventions used for real input.
The default value of s assumes an even output length in the final transformation axis. When performing the final complex to real transformation, the Hermitian symmetry requires that the last imaginary component along that axis must be 0 and so it is ignored. To avoid losing information, the correct length of the real input must be given.
Array API Standard Support
irfftn has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ✅ PyTorch ✅ ✅ JAX ✅ ✅ Dask ⚠️ computes graph n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
import scipy.fft import numpy as np x = np.zeros((3, 2, 2)) x[0, 0, 0] = 3 * 2 * 2✓
scipy.fft.irfftn(x)
✗See also
- fft
The 1-D FFT, with definitions and conventions used.
- irfft
The inverse of the 1-D FFT of real input.
- irfft2
The inverse of the 2-D FFT of real input.
- rfftn
The forward N-D FFT of real input, of which
ifftnis the inverse.
Aliases
-
scipy.fft.irfftn