rfft2

paddle.fft. rfft2 ( x, s=None, axes=(- 2, - 1), norm='backward', name=None ) [source]

The two dimensional FFT with real tensor input.

This is really just rfftn with different default behavior. For more details see rfftn.

Parameters
  • x (Tensor) – Input tensor, taken to be real.

  • s (Sequence[int]) – Shape of the FFT.

  • axes (Sequence[int], optional) – Axes over which to compute the FFT.

  • norm (str, optional) – {“backward”, “ortho”, “forward”}, default is “backward”. Indicates which direction of the forward/backward pair of transforms is scaled and with what normalization factor.

  • 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 .

Returns

The result of the real 2-D FFT.

Return type

out(Tensor)

Raises:

Examples:

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/fft.py:docstring of paddle.fft.rfft2, line 30)

Error in “code-block” directive: maximum 1 argument(s) allowed, 7 supplied.

.. code-block:: python
    import paddle
    import numpy as np

    x = paddle.to_tensor(np.mgrid[:5, :5][0].astype(np.float32))
    print(paddle.fft.rfft2(x))
    # Tensor(shape=[5, 3], dtype=complex64, place=CUDAPlace(0), stop_gradient=True,
    #        [[ (50+0j)                                        ,  (1.1920928955078125e-07+0j)                    ,  0j                                             ],
    #         [(-12.5+17.204774856567383j)                     , (-9.644234211236835e-08+7.006946134424652e-08j) ,  0j                                             ],
    #         [(-12.500000953674316+4.061495304107666j)        , (3.6837697336977726e-08-1.1337477445749755e-07j),  0j                                             ],
    #         [(-12.500000953674316-4.061495304107666j)        , (3.6837697336977726e-08+1.1337477445749755e-07j),  0j                                             ],
    #         [(-12.5-17.204774856567383j)                     , (-9.644234211236835e-08-7.006946134424652e-08j) ,  0j                                             ]])