irfft
→Tensorirfft(input: Tensor, n: int | None = None, dim: int = -1, norm: str | None = None)1-D inverse FFT for a Hermitian-symmetric spectrum.
Computes the inverse one-dimensional FFT of a conjugate-symmetric
(Hermitian) spectrum, as produced by rfft, and returns a
real-valued output.
Given an input of length , the
full-length real output has length . The default assumption
is that (even); supply n explicitly when the
original signal length was odd.
Parameters
inputTensorrfft), of any shape.nint= NoneNone, the output
length defaults to where is the
input axis length. Pass the original signal length to avoid
the even/odd ambiguity.dimint= -1-1 (last axis).normstr or None= None"backward" (default), "forward", or
"ortho". See fftn for the full description.Returns
TensorReal tensor (float32) with the same shape as input
except that axis dim has length n (or
when n is None).
Notes
Odd-length signals — if the original real signal had odd length
, the rfft output has bins. The
default rule gives instead of .
Always pass n=N explicitly when the original length was odd.
Normalisation parity — to faithfully invert rfft, use
the same norm value for both the forward and inverse calls.
Examples
Round-trip with explicit length:
>>> x = lucid.randn(100) # odd length
>>> X = lucid.fft.rfft(x)
>>> X.shape # 51
(51,)
>>> x_rec = lucid.fft.irfft(X, n=100)
>>> x_rec.shape
(100,)
Default (even-length assumption):
>>> X = lucid.fft.rfft(lucid.randn(128))
>>> lucid.fft.irfft(X).shape # 2*(65-1) = 128
(128,)