fn

ifftn

Tensor
ifftn(input: Tensor, s: int | Sequence[int] | None = None, dim: int | Sequence[int] | None = None, norm: str | None = None)
source

N-dimensional inverse discrete Fourier transform.

Recovers the original signal from its frequency-domain representation produced by fftn. For a single axis of length NN, 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 shown above corresponds to norm='backward' (the default). With norm='forward' the factor becomes 1 (unscaled), and with norm='ortho' it becomes 1/N1/\sqrt{N}.

Parameters

inputTensor
Complex input tensor (frequency domain), of any shape.
sint or sequence of int= None
Output signal length(s) along each transformed axis. The frequency-domain tensor is zero-padded or truncated to match before inverting. len(s) must equal len(dim) when both are sequences. If None, each axis keeps its current size.
dimint or sequence of int= None
Axis or axes over which to compute the inverse transform. Negative indices are supported. Defaults to all axes.
normstr or None= None
Normalisation mode. One of:
  • "backward" (default, same as None) — divides by NN (standard inverse-DFT convention).
  • "forward" — no division; assumes the forward transform divided by NN.
  • "ortho" — divides by N\sqrt{N}, matching fftn with norm='ortho'.

Returns

Tensor

Complex tensor (complex64) with the same shape as input except that each transformed axis i has length s[i] (or the input size when s is None).

Notes

Round-trip property — for any complex tensor x:

ifftn(fftn(x,norm=m),norm=m)x\text{ifftn}(\text{fftn}(x, \text{norm}=m), \text{norm}=m) \approx x

up to floating-point rounding, for any valid norm mode m.

Conjugate symmetry — if the input to fftn was a real tensor, its DFT satisfies X[Nk]=X[k]X[N-k] = X^*[k]. In that case irfftn is preferred because it exploits this symmetry to produce a real output more efficiently.

Examples

Round-trip through the frequency domain:
>>> x = lucid.randn(32)
>>> X = lucid.fft.fftn(x)
>>> x_rec = lucid.fft.ifftn(X)
>>> # x_rec.real ≈ x  (imaginary part is ≈ 0 for a real input)
Inverse of a 2-D transform:
>>> X = lucid.fft.fftn(lucid.ones(8, 8))
>>> x = lucid.fft.ifftn(X)
>>> x.shape
(8, 8)