ifft — Compute inverse discrete Fourier transforms in MATLAB and RunMat.
ifft(X) computes the inverse discrete Fourier transform of X. By default it operates along the first non-singleton dimension, with optional length, dimension, and symmetry forms following MATLAB semantics.
Syntax
Y = ifft(X)
Y = ifft(X, N)
Y = ifft(X, symflag)
Y = ifft(X, N, DIM)
Y = ifft(X, N, symflag)
Y = ifft(X, N, DIM, symflag)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
X | Any | Yes | — | Input spectrum or signal. |
N | NumericScalar | No | [] | Transform length along selected dimension. |
symflag | StringScalar | No | "nonsymmetric" | Symmetry flag: "symmetric" or "nonsymmetric". |
DIM | NumericScalar | No | first non-singleton dimension | Dimension to transform along. |
Returns
| Name | Type | Description |
|---|---|---|
Y | NumericArray | Inverse FFT result. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:ifft:ArgCount | More than four input arguments are supplied. | ifft: invalid argument count |
RunMat:ifft:InvalidLength | Length argument N is invalid. | ifft: invalid length argument |
RunMat:ifft:InvalidDimension | Dimension argument DIM is invalid. | ifft: invalid dimension argument |
RunMat:ifft:InvalidSymflag | Symmetry flag is invalid or appears in an invalid position. | ifft: invalid symmetry flag usage |
RunMat:ifft:InvalidInput | Input cannot be converted to supported numeric/complex domain. | ifft: invalid input |
RunMat:ifft:Internal | IFFT execution or tensor shaping fails. | ifft: internal error |
How ifft works
ifft(X)transforms along the first dimension whose size is greater than 1.ifft(X, N)zero-pads or truncatesXto lengthNbefore applying the transform.ifft(X, N, DIM)applies the transform along dimensionDIM.ifft(X, [], DIM)keeps the existing length and transforms along dimensionDIM.ifft(..., 'symmetric')forces the output to be real-valued, mirroring MATLAB's handling of conjugate-symmetric spectra.ifft(..., 'nonsymmetric')keeps the default complex result; it is equivalent to omitting the symmetry flag but is accepted for MATLAB compatibility.- Empty inputs and dimensions larger than the rank of
Xmirror MATLAB behaviour.
Does RunMat run ifft on the GPU?
RunMat keeps gpuArray inputs on the device long enough to query the active acceleration provider for the ifft_dim hook. When the hook is present, the inverse transform executes on the device, after which RunMat immediately downloads the result to return the standard MATLAB host types. If the provider lacks that hook—or if the requested length is zero—the runtime gathers the data once, evaluates the inverse transform on the CPU via rustfft, and returns a MATLAB-compatible result.
GPU memory and residency
RunMat's auto-offload system keeps tensors on the GPU when profitable, so explicit gpuArray calls are rarely required. They remain available to mirror MATLAB workflows. When the provider lacks an inverse FFT hook, RunMat automatically gathers once, evaluates the transform on the host, and returns the result, so manual residency management is unnecessary.
Examples
Reconstructing a time-domain signal from FFT bins
Y = [10 -2+2i -2 -2-2i];
x = ifft(Y)Expected output:
x =
Columns 1 through 4
1 2 3 4Computing ifft along a specific dimension
F = [10 14 18;
-3+3i -3+3i -3+3i];
X = ifft(F, [], 1)Zero-padding the inverse transform
F = [4 0 0 0];
x = ifft(F, 8)Enforcing a real result with 'symmetric'
F = fft([1 2 3 4]);
x = ifft(F, 'symmetric')Running ifft on gpuArray inputs
G = gpuArray(fft([1 0 0 0]));
X = ifft(G);
result = gather(X)Using ifft with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how ifft changes the result.
Run a small ifft example, explain the result, then change one input and compare the output.
FAQ
Does ifft always return complex values?⌄
By default, yes. The 'symmetric' flag converts the result to a real array when the spectrum is conjugate-symmetric. You can also pass 'nonsymmetric' to state this default explicitly while keeping the complex result.
How does ifft scale the result?⌄
RunMat divides by the transform length so that ifft(fft(x)) reproduces x, matching MATLAB.
Can I omit the length but specify a dimension?⌄
Yes. Use an empty array for the length: ifft(X, [], DIM).
What happens if I request a zero length?⌄
You receive an empty array along the selected dimension, mirroring MATLAB behaviour.
Does 'symmetric' validate conjugate symmetry?⌄
No. Like MATLAB, RunMat assumes the spectrum is conjugate-symmetric and simply discards imaginary components.
Will RunMat run the inverse FFT on the GPU automatically?⌄
Only when the provider exposes an inverse FFT kernel (ifft_dim). Otherwise, the runtime gathers to the host transparently.
How do I perform multi-dimensional inverse transforms?⌄
Apply ifft sequentially along each dimension (e.g., ifft(ifft(X, [], 1), [], 2)).
Related Math functions
Elementwise
abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times
Trigonometry
acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · deg2rad · rad2deg · sin · sind · sinh · tan · tand · tanh
Reduction
all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var
Structure
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how ifft is executed, line by line, in Rust.
- View the source for ifft in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.