RunMat
GitHub

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

NameTypeRequiredDefaultDescription
XAnyYesInput spectrum or signal.
NNumericScalarNo[]Transform length along selected dimension.
symflagStringScalarNo"nonsymmetric"Symmetry flag: "symmetric" or "nonsymmetric".
DIMNumericScalarNofirst non-singleton dimensionDimension to transform along.

Returns

NameTypeDescription
YNumericArrayInverse FFT result.

Errors

IdentifierWhenMessage
RunMat:ifft:ArgCountMore than four input arguments are supplied.ifft: invalid argument count
RunMat:ifft:InvalidLengthLength argument N is invalid.ifft: invalid length argument
RunMat:ifft:InvalidDimensionDimension argument DIM is invalid.ifft: invalid dimension argument

How ifft works

  • ifft(X) transforms along the first dimension whose size is greater than 1.
  • ifft(X, N) zero-pads or truncates X to length N before applying the transform.
  • ifft(X, N, DIM) applies the transform along dimension DIM.
  • ifft(X, [], DIM) keeps the existing length and transforms along dimension DIM.
  • 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 X mirror 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     4

Computing 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)).

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

Signal

blackman · conv · conv2 · deconv · filter · hamming · hann · sawtooth · sinc · square

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · eig · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · pinv · rank · rcond

Interpolation

interp1 · interp2 · pchip · ppval · spline

Ode

ode15s · ode23 · ode45

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how ifft is executed, line by line, in Rust.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.