fn

ihfft2

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

2-D inverse FFT of a real signal, giving a Hermitian half-spectrum.

Computes the inverse of hfft2: given a real-valued 2-D input, returns the conjugated one-sided 2-D spectrum (the Hermitian half-spectrum). This is the 2-D specialisation of ihfftn.

For an input of shape (M,N)(M, N), the output shape is (M,N//2+1)(M, N//2 + 1) — full along the first axis and compressed along the last.

Parameters

inputTensor
Real-valued input tensor with at least 2 dimensions.
ssequence of int= None
Signal sizes (M_out, N_out) along the two transformed axes. If None, current axis sizes are used.
dimsequence of int= (-2, -1)
The two axes over which to compute the transform. Default is (-2, -1).
normstr or None= None
Normalisation mode — "backward" (default), "forward", or "ortho". See fftn for the full description.

Returns

Tensor

Complex tensor (complex64) with the same shape as input except the last transformed axis has length N/2+1\lfloor N/2 \rfloor + 1.

Notes

Round-trip with hfft2 — for a real tensor x of shape (M,N)(M, N):

hfft2(ihfft2(x),s=[M,N])x.\text{hfft2}(\text{ihfft2}(x), s=[M, N]) \approx x.

Examples

Compute the Hermitian half-spectrum of a 2-D real image:
>>> x = lucid.randn(64, 64)
>>> H = lucid.fft.ihfft2(x)
>>> H.shape   # last axis: 64 // 2 + 1 = 33
(64, 33)
Round-trip:
>>> x_rec = lucid.fft.hfft2(H, s=[64, 64])
>>> x_rec.shape
(64, 64)