fn

hfft

Tensor
hfft(input: Tensor, n: int | None = None, dim: int = -1, norm: str | None = None)
source

1-D FFT of a Hermitian-symmetric complex signal.

Computes the one-dimensional DFT of a Hermitian (conjugate-symmetric) signal stored as a one-sided half-spectrum, returning a real-valued output. This is the 1-D specialisation of hfftn.

A Hermitian signal satisfies x[Nk]=x[k]x[N-k] = x^*[k], so only N/2+1\lfloor N/2 \rfloor + 1 complex values need to be given as input. The transform is mathematically:

y[n]=k=0N1x[k]ei2πkn/N,n=0,,N1,y[n] = \sum_{k=0}^{N-1} x[k]\, e^{-i 2\pi k n / N}, \quad n = 0, \ldots, N-1,

where the full spectrum x[k]x[k] is reconstructed from the half-spectrum by Hermitian extension before the sum is evaluated.

Parameters

inputTensor
Complex half-spectrum tensor of any shape. Axis dim is expected to have length N/2+1\lfloor N/2 \rfloor + 1.
nint= None
Full length of the output (real) axis. If None, the output defaults to 2(m1)2(m-1) where mm is the input axis length. Specify n explicitly when the original signal length was odd.
dimint= -1
Axis over which to compute the transform. Default is -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 that axis dim has length n (or 2(m1)2(m-1) when n is None).

Notes

Usage patternhfft is rarely needed in signal processing pipelines that use the standard rfft / irfft pair. It becomes useful when working in the frequency domain: if you have synthesised or modified a Hermitian spectrum directly and want to recover the implied real time-domain signal, hfft does it in one call without needing to materialise the full (redundant) spectrum.

Examples

Construct a Hermitian half-spectrum and recover the real signal:
>>> half_spec = lucid.randn(33)  # half-spectrum for N=64
>>> y = lucid.fft.hfft(half_spec, n=64)
>>> y.shape
(64,)
Round-trip with ``ihfft``:
>>> x = lucid.randn(64)
>>> H = lucid.fft.ihfft(x)
>>> x_rec = lucid.fft.hfft(H, n=64)
>>> x_rec.shape
(64,)