fn

ihfftn

Tensor
ihfftn(input: Tensor, s: int | Sequence[int] | None = None, dim: int | Sequence[int] | None = None, norm: str | None = None)
source

N-dimensional inverse FFT of a real-valued signal, giving a Hermitian output.

Computes the inverse of hfftn: given a real-valued input, produces the conjugate-symmetric half-spectrum. The implementation uses the identity:

ihfftn(x,s,norm)=rfftn(x,s,norm=dual(norm)),\text{ihfftn}(x, s, \text{norm}) = \overline{\text{rfftn}(x, s, \text{norm}=\text{dual}(\text{norm}))},

where ()\overline{(\cdot)} denotes complex conjugation.

Equivalently, ihfftn computes the backward-sign DFT (e+i2πkn/Ne^{+i2\pi kn/N}) of the real input and returns only the first N/2+1\lfloor N/2 \rfloor + 1 bins along the last transformed axis, exactly mirroring the output format of rfft.

Parameters

inputTensor
Real-valued input tensor of any shape.
sint or sequence of int= None
Signal length(s) along each transformed axis. The last value determines the full real length, and the output last axis will be s[-1] // 2 + 1. If None, current axis sizes are used.
dimint or sequence of int= None
Axis or axes over which to compute the transform. Defaults to all axes.
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 that the last transformed axis has length N/2+1\lfloor N/2 \rfloor + 1.

Notes

Round-trip with hfftn — for a real tensor x:

hfftn(ihfftn(x,s,norm=m),s,norm=m)x.\text{hfftn}(\text{ihfftn}(x, s, \text{norm}=m), s, \text{norm}=m) \approx x.

Relationship to rfft — the output of ihfftn with norm='backward' has the same element magnitudes as rfft with norm='backward' but the signs of the imaginary parts are negated (due to the conjugation in the identity above).

Examples

Compute the Hermitian half-spectrum of a real signal:
>>> x = lucid.randn(128)
>>> H = lucid.fft.ihfftn(x)
>>> H.shape   # 128 // 2 + 1 = 65
(65,)
Round-trip:
>>> x_rec = lucid.fft.hfftn(H, s=[128])
>>> x_rec.shape
(128,)