irfft#
-
nvmath.
fft. irfft( - operand,
- axes=None,
- options=None,
- execution=None,
- prolog=None,
- epilog=None,
- stream=None,
Perform an N-D complex-to-real (C2R) FFT on the provided complex operand. The direction is implicitly inverse.
- Parameters:
operand – A tensor (ndarray-like object). The currently supported types are
numpy.ndarray
,cupy.ndarray
, andtorch.Tensor
.axes – The dimensions along which the FFT is performed.
axes[-1]
is the ‘last transformed’ axis for rffts. Currently, it is required that the axes are contiguous and include the first or the last dimension. Only up to 3D FFTs are supported.options – Specify options for the FFT as a
FFTOptions
object. Alternatively, adict
containing the parameters for theFFTOptions
constructor can also be provided. If not specified, the value will be set to the default-constructedFFTOptions
object.prolog – Provide device-callable function in LTO-IR format to use as load-callback as an object of type
DeviceCallable
. Alternatively, adict
containing the parameters for theDeviceCallable
constructor can also be provided. The default is no prolog. Currently, callbacks are supported only with CUDA execution.epilog – Provide device-callable function in LTO-IR format to use as store-callback as an object of type
DeviceCallable
. Alternatively, adict
containing the parameters for theDeviceCallable
constructor can also be provided. The default is no epilog. Currently, callbacks are supported only with CUDA execution.stream – Provide the CUDA stream to use for executing the operation. Acceptable inputs include
cudaStream_t
(as Pythonint
),cupy.cuda.Stream
, andtorch.cuda.Stream
. If a stream is not provided, the current stream from the operand package will be used.
- Returns:
A real tensor that remains on the same device and belongs to the same package as the input operand. The extent of the last transformed axis in the result will be
(operand.shape[axes[-1]] - 1) * 2
ifFFTOptions.last_axis_size
iseven
, oroperand.shape[axes[-1]] * 2 - 1
ifFFTOptions.last_axis_size
isodd
.
Examples
>>> import cupy as cp >>> import nvmath
Create a 3-D symmetric complex128 ndarray on the GPU:
>>> shape = 512, 768, 256 >>> a = nvmath.fft.rfft(cp.random.rand(*shape, dtype=cp.float64))
Perform a 3-D C2R FFT using the
irfft()
wrapper. The resultr
is a CuPy float64 ndarray:>>> r = nvmath.fft.irfft(a) >>> r.dtype
Notes
This function performs an inverse C2R N-D FFT, which is similar to
irfftn
but different fromirfft
in various numerical packages.This function is a convenience wrapper around
FFT
and and is specifically meant for single use. The same computation can be performed with the stateful API by settingFFTOptions.fft_type
to'C2R'
and passing the argumentdirection='inverse'
when callingFFT.execute()
.The input to this function must be Hermitian-symmetric, otherwise the result is undefined. While the symmetry requirement is partially captured by the different extents in the last transformed dimension between the input and result, there are additional constraints. As a specific example, 1-D transforms require the first element (and the last element, if the extent is even) of the input to be purely real-valued. In addition, if the input to
irfft
was generated using an R2C FFT with an odd last axis size,FFTOptions.last_axis_size
must be set toodd
to recover the original signal.For more details, please refer to C2R example and odd C2R example.