hfftn
→Tensorhfftn(input: Tensor, s: int | Sequence[int] | None = None, dim: int | Sequence[int] | None = None, norm: str | None = None)N-dimensional FFT of a Hermitian-symmetric complex signal.
Computes the N-dimensional DFT of a signal that is known to be
Hermitian (conjugate-symmetric), producing a real-valued output.
The input is the half-spectrum as conventionally stored by
rfftn or constructed manually: the first
bins along the last transformed axis, with no redundancy stored.
The implementation uses the identity:
where is the element-wise complex conjugate and
dual swaps "backward" ↔ "forward" while leaving
"ortho" unchanged. This is mathematically equivalent to a
forward DFT on a Hermitian signal: conjugating the input flips the
sign in the exponent, converting the inverse-real transform into a
forward-real one.
Parameters
inputTensorsint or sequence of int= NoneNone, the last axis defaults to where
is the input last-axis length.dimint or sequence of int= Nonenormstr or None= None"backward" (default), "forward", or
"ortho". Note that the dual normalisation is applied
internally; the semantics mirror those of fftn.Returns
TensorReal tensor (float32) whose shape matches input except
that the last transformed axis has length s[-1] (or
when s is None), and all other
transformed axes have lengths s[i].
Notes
Relationship to rfft / irfft — the Hermitian FFT pair
(hfftn / ihfftn) is the Fourier-domain dual of the real
FFT pair (rfftn / irfftn):
rfftntakes a real time-domain signal → half complex spectrum.hfftntakes a half complex Hermitian signal (frequency domain) → real output in the transform domain.
Sign convention — hfftn uses the forward FFT sign
convention () applied to the Hermitian input.
This means applying hfftn followed by ihfftn recovers the
original half-spectrum (up to floating-point rounding).
Examples
Recover a real spectrum from a Hermitian half-spectrum:
>>> x_complex = lucid.randn(33) # half-spectrum for N=64
>>> y = lucid.fft.hfftn(x_complex, s=[64])
>>> y.shape
(64,)
N-dimensional example:
>>> x = lucid.randn(16, 33) # last axis: 33 = 64//2+1
>>> y = lucid.fft.hfftn(x, s=[16, 64])
>>> y.shape
(16, 64)