- paddle.fft. irfft ( x, n=None, axis=- 1, norm='backward', name=None )
Computes the inverse of rfft.
This function calculates the inverse of the one-dimensional n point discrete Fourier transform of the actual input calculated by “rfft”. In other words,
irfft(rfft(a),len(a)) == ais within the numerical accuracy range.
The input shall be in the form of “rfft”, i.e. the actual zero frequency term, followed by the complex positive frequency term, in the order of increasing frequency. Because the discrete Fourier transform of the actual input is Hermite symmetric, the negative frequency term is regarded as the complex conjugate term of the corresponding positive frequency term.
x (Tensor) – The input data. It’s a Tensor type. It’s a complex.
n (int, optional) – The length of the output transform axis. For n output points,
n//2 + 1``input points are necessary. If the length of the input tensor is greater than `n`, it will be cropped, if it is shorter than this, fill in zero. If `n` is not given, it is considered to be ``2 * (k-1), where
kis the length of the input axis specified along the ` axis’.
axis (int, optional) – Axis used to calculate FFT. If not specified, the last axis is used by default.
norm (str) – 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”.
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 .
Real tensor. Truncated or zero fill input for the transformation along the axis indicated by axis, or the last input if axis is not specified. The length of the conversion axis is n, or
2 * k-2, if k is None, where k is the length of the input conversion axis. If the output is an odd number, you need to specify the value of ‘n’, such as
2 * k-1in some cases.
import numpy as np import paddle x = np.array([1, -1j, -1]) xp = paddle.to_tensor(x) irfft_xp = paddle.fft.irfft(xp).numpy() print(irfft_xp) # [0. 1. 0. 0.]