fn
ihfft
→Tensorihfft(input: Tensor, n: int | None = None, dim: int = -1, norm: str | None = None)1-D inverse FFT of a real signal, giving a Hermitian half-spectrum.
Computes the inverse of hfft: given a real-valued input,
returns the conjugate of its one-sided real FFT. The output is
complex and has length along
axis dim.
Mathematically:
where denotes complex conjugation and
the dual normalisation is applied to match hfft.
Parameters
inputTensorReal-valued input tensor of any shape.
nint= NoneNumber of input samples to use. If
None, the full axis
length is used.dimint= -1Axis over which to compute the transform. Default is
-1.normstr or None= NoneNormalisation mode —
"backward" (default), "forward", or
"ortho". See fftn for the full description.Returns
TensorComplex tensor (complex64) with the same shape as input
except that axis dim has length .
Notes
Round-trip with hfft — for a real tensor x of length
:
Negative imaginary parts — because ihfft conjugates the
rfft output, the imaginary parts of the result are the negatives
of those from rfft. For a real input, rfft(x)[0] and
rfft(x)[N//2] (for even ) are both real, so
ihfft(x)[0] and ihfft(x)[N//2] are also real.
Examples
Compute the Hermitian half-spectrum:
>>> x = lucid.randn(64)
>>> H = lucid.fft.ihfft(x)
>>> H.shape # 64 // 2 + 1 = 33
(33,)
Round-trip check:
>>> x_rec = lucid.fft.hfft(H, n=64)
>>> x_rec.shape
(64,)