Skip to content

IRFFT

Inverse of rfft: onesided bins back to the real signal, scaled by 1 / n. Any length, any backend, differentiable on torch.

specux.irfft(X, n=None, backend="auto", out=None) # -> (..., n) real
x = np.random.randn(8, 4096).astype(np.float32)
F = specux.rfft(x)
y = specux.irfft(F, x.shape[-1]) # recovers x to float32 rounding

n defaults to 2 * (X.shape[-1] - 1); pass it explicitly to recover odd lengths. out= and large lengths behave exactly as on rfft (copy semantics; the fused factor pipeline past the single-block sizes).

Parameters

  • X: onesided complex rows shaped (..., n // 2 + 1).
  • n: the real output length; defaults to 2 * (X.shape[-1] - 1).
  • backend: "auto" follows the input’s device.
  • out: optional preallocated result buffer (copy semantics).

The configured form

F = specux.rfft(np.random.randn(8, 4096).astype(np.float32))
inv = specux.IRFFT(n=4096) # binds the odd/even length choice
y = inv(F)

For repeated same-length pairs, fft_plan.