fn

irfft2

Tensor
irfft2(input: Tensor, s: Sequence[int] | None = None, dim: Sequence[int] = (-2, -1), norm: str | None = None)
source

2-D inverse FFT for a Hermitian-symmetric spectrum.

Recovers a real 2-D signal from its one-sided 2-D spectrum as produced by rfft2. The output is guaranteed to be real-valued.

For an input of shape (M,m)(M, m) where m=N/2+1m = \lfloor N/2 \rfloor + 1, the default full output size is (M,2(m1))(M, 2(m-1)) (assuming an even last-axis length NN).

Parameters

inputTensor
Complex Hermitian tensor (one-sided 2-D spectrum) with at least 2 dimensions, typically the output of rfft2.
ssequence of int= None
Full output sizes (M_out, N_out) along the two transformed axes. Pass the original signal shape to avoid the even/odd ambiguity in the last axis. If None, the last axis defaults to 2(m1)2(m-1).
dimsequence of int= (-2, -1)
The two axes over which to compute the inverse transform. Default is (-2, -1).
normstr or None= None
Normalisation mode — "backward" (default), "forward", or "ortho". See fftn for the full description.

Returns

Tensor

Real tensor (float32) with the same shape as input except the two transformed axes have lengths s[0] and s[1] (or inferred sizes when s is None).

Notes

Odd-length last axis — if the original image had an odd number of columns NN, always pass s=[M, N] explicitly.

Examples

Round-trip for a 128×256 image:
>>> x = lucid.randn(128, 256)
>>> X = lucid.fft.rfft2(x)
>>> X.shape   # (128, 129)
(128, 129)
>>> x_rec = lucid.fft.irfft2(X, s=[128, 256])
>>> x_rec.shape
(128, 256)