fn

ifft

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

1-D inverse discrete Fourier transform along a single axis.

Recovers the time-domain signal from its frequency-domain representation computed by fft. For a complex frequency sequence X[0],,X[N1]X[0], \ldots, X[N-1], the inverse DFT is:

x[n]=1Nk=0N1X[k]e+i2πkn/N,n=0,1,,N1.x[n] = \frac{1}{N} \sum_{k=0}^{N-1} X[k]\, e^{+i 2\pi k n / N}, \quad n = 0, 1, \ldots, N-1.

The 1/N1/N factor above corresponds to norm='backward' (default). With norm='ortho' both fft and ifft divide by N\sqrt{N}, making the pair a unitary transform.

Parameters

inputTensor
Complex input tensor (frequency domain) of any shape.
nint= None
Length of the output (time-domain) axis. The frequency-domain axis is zero-padded or truncated to match before inverting. If None, the axis keeps its current length.
dimint= -1
Axis over which to compute the inverse transform. Default is -1 (last axis).
normstr or None= None
Normalisation mode — "backward" (default), "forward", or "ortho". See fftn for the full description.

Returns

Tensor

Complex tensor (complex64) with the same shape as input except that axis dim has length n (or the input length when n is None).

Notes

Round-trip — for any complex tensor x:

ifft(fft(x))x\text{ifft}(\text{fft}(x)) \approx x

up to floating-point rounding.

Real inputs — if input represents the spectrum of a real signal (conjugate-symmetric), the imaginary part of the output will be negligibly small. Use irfft to obtain a strictly real output more efficiently when you know the input is conjugate-symmetric.

Examples

Round-trip reconstruction:
>>> x = lucid.randn(64)
>>> X = lucid.fft.fft(x)
>>> x_rec = lucid.fft.ifft(X)
>>> x_rec.shape
(64,)
>>> # x_rec.real ≈ x
Deconvolution in the frequency domain:
>>> H = lucid.fft.fft(lucid.randn(32))   # frequency response
>>> Y = lucid.fft.fft(lucid.randn(32))   # observed output spectrum
>>> x_est = lucid.fft.ifft(Y / H)        # estimated input