irfftn
→Tensorirfftn(input: Tensor, s: int | Sequence[int] | None = None, dim: int | Sequence[int] | None = None, norm: str | None = None)N-dimensional inverse FFT for a Hermitian-symmetric spectrum.
Computes the inverse N-dimensional FFT assuming the input is
conjugate-symmetric (Hermitian), as produced by rfftn.
The output is guaranteed to be real-valued.
For the last transformed axis, the full-length signal size must be
specified or inferred: given an input last-axis of length
, the default assumed full length
is (even). Supply s[-1] explicitly when
the original signal length was odd.
Parameters
inputTensorrfftn.sint or sequence of int= Nones[i] may equal the
corresponding input axis length. If None, the last axis
output length defaults to where is
the input last-axis length; all other axes keep their input sizes.dimint or sequence of int= Nonenormstr or None= None"backward" (default), "forward", or
"ortho". See fftn for the full description.Returns
TensorReal tensor (float32) whose shape matches input except:
- The last transformed axis has length
s[-1](or by default, where is the input last-axis length). - All other transformed axes have lengths
s[i](or input sizes whensisNone).
Notes
Specifying odd-length signals — if the original real signal had
an odd length (so the rfft output had
bins), you must pass s=[N] explicitly. Without it the default
rule would give (even), producing the
wrong output length.
Round-trip — for a real tensor x:
where s should contain the original axis sizes to avoid the
even/odd ambiguity.
Examples
Round-trip through the real FFT:
>>> x = lucid.randn(128)
>>> X = lucid.fft.rfftn(x)
>>> X.shape
(65,)
>>> x_rec = lucid.fft.irfftn(X, s=[128])
>>> x_rec.shape
(128,)
3-D round-trip:
>>> x = lucid.randn(16, 32, 64)
>>> X = lucid.fft.rfftn(x)
>>> x_rec = lucid.fft.irfftn(X, s=[16, 32, 64])
>>> x_rec.shape
(16, 32, 64)