flopscope.numpy.fft.rfft2
fnp.fft.rfft2(a, s=None, axes=(-2, -1), norm=None, out=None)[flopscope source][numpy source]
Compute the 2-dimensional FFT of a real array.
Adapted from NumPy docs np.fft.rfft2
2-D real FFT. Cost: staged -- replays numpy's cascade as a real FFT on the last axis followed by complex FFTs over the remaining axes (forward order), with batch at each stage taken from the shape at that point in the cascade (not the final transform shape); the Hermitian reduction after the first stage changes the batch seen by later stages, so this no longer reduces to a uniform 5*(N//2)*sum(ceil(log2(s_i))) even without resizing. Cost formula already counts complex real-FLOPs; priced-in.
Parameters
- a:array
Input array, taken to be real.
- s:sequence of ints, optional
Shape of the FFT.
Changed in version 2.0.Deprecated since 2.0.Deprecated since 2.0.- axes:sequence of ints, optional
Axes over which to compute the FFT. Default:
(-2, -1).Deprecated since 2.0.- norm:{"backward", "ortho", "forward"}, optional
Normalization mode (see flops.fft). Default is "backward". Indicates which direction of the forward/backward pair of transforms is scaled and with what normalization factor.
Added in version 1.20.0.- out:complex ndarray, optional
If provided, the result will be placed in this array. It should be of the appropriate shape and dtype for the last inverse transform. incompatible with passing in all but the trivial
s).Added in version 2.0.0.
Returns
- out:ndarray
The result of the real 2-D FFT.
See also
- rfftn Compute the N-dimensional discrete Fourier Transform for real input.
Notes
This is really just rfftn with different default behavior.
For more details see rfftn.
Examples
>>> import flopscope.numpy as fnp
>>> a = flops.mgrid[:5, :5][0]
>>> flops.fft.rfft2(a)
array([[ 50. +0.j , 0. +0.j , 0. +0.j ],
[-12.5+17.20477401j, 0. +0.j , 0. +0.j ],
[-12.5 +4.0614962j , 0. +0.j , 0. +0.j ],
[-12.5 -4.0614962j , 0. +0.j , 0. +0.j ],
[-12.5-17.20477401j, 0. +0.j , 0. +0.j ]])