RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • fft
    • fft2
    • fftn
    • fftshift
    • ifft
    • ifft2
    • ifftn
    • ifftshift

ifft2 — Compute two-dimensional inverse Fourier transforms in MATLAB and RunMat.

ifft2(X) computes the two-dimensional inverse discrete Fourier transform of X. Documented integer data through 32 bits enters the double transform domain; host int64 and uint64 data and shorthand size forms are exactness-checked RunMat extensions.

Syntax

Y = ifft2(X)
Y = ifft2(X, SIZE)
Y = ifft2(X, M, N)
Y = ifft2(X, symflag)
Y = ifft2(X, SIZE, symflag)
Y = ifft2(X, M, N, symflag)

Inputs

NameTypeRequiredDefaultDescription
XAnyYes—Input spectrum or signal.
SIZENumericArrayNo[]Scalar N or two-element [M N] size vector.
MNumericScalarNo[]Output row count for transform.
NNumericScalarNo[]Output column count for transform.
symflagStringScalarNo"nonsymmetric"Symmetry flag: "symmetric" or "nonsymmetric".

Returns

NameTypeDescription
YNumericArray2-D inverse FFT output.

Errors

IdentifierWhenMessage
RunMat:ifft2:ArgCountMore than four input arguments are supplied.ifft2: invalid argument count
RunMat:ifft2:InvalidLengthLength/size arguments are invalid.ifft2: invalid transform length argument
RunMat:ifft2:InvalidSizeVectorSingle SIZE argument is invalid.ifft2: invalid size vector argument
RunMat:ifft2:InvalidSymflagSymmetry flag is invalid or appears in an invalid position.ifft2: invalid symmetry flag usage
RunMat:ifft2:InvalidInputInput cannot be converted to supported numeric/complex domain.ifft2: invalid input
RunMat:ifft2:InternalIFFT2 execution or tensor shaping fails.ifft2: internal error
RunMat:ifft2:ProviderIntegrityThe provider returns ownership, shape, or physical metadata inconsistent with the request.ifft2: provider integrity error

How ifft2 works

  • ifft2(X) transforms along the first two dimensions whose sizes exceed one.
  • ifft2(X, M, N) zero-pads or truncates the spectrum to M rows and N columns before the inverse.
  • ifft2(X, SIZE) accepts a scalar or two-element vector describing the transform lengths.
  • ifft2(..., 'symmetric') discards tiny imaginary parts and returns a real matrix when the spectrum is conjugate-symmetric. 'nonsymmetric' keeps the complex result.
  • Higher-dimensional inputs are processed slice-by-slice across trailing dimensions.
  • Empty or zero size controls and scalar/two-element SIZE shorthand are independently gated RunMat extensions.
  • Provider results must be fresh, correctly shaped, complex, physically precise, and owned by the input provider; only an unsupported hook falls back through exact host storage.

GPU memory and residency

RunMat resolves execution through the provider that owns the input handle. Valid nonsymmetric floating results remain resident. Symmetric output and explicit unsupported-hook fallback may download internally; RunMat restores the result only when the owner can physically preserve its class, otherwise it returns the correctly typed host value.

Examples

Reconstructing an image patch from its 2-D spectrum

F = [10  -2  0  -2;
     -4   0  0   0];
x = ifft2(F)

Expected output:

x =
    1.0000    2.0000
    3.0000    4.0000

Zero-padding before the inverse transform

F = fft2([1 0; 0 1], 4, 4);
spatial = ifft2(F, 4, 4)

Supplying transform lengths with a size vector

Y = fft2(rand(3,4));
X = ifft2(Y, [5 2]);   % pad rows to 5, truncate columns to 2

Forcing a real-valued result with 'symmetric'

F = fft2([1 2; 3 4]);
realImage = ifft2(F, 'symmetric')

Running ifft2 on gpuArray inputs

G = gpuArray(fft2(peaks(64)));
spatial = ifft2(G);
result = gather(spatial)

Recovering each slice of a volume

spectra = fft2(rand(16, 16, 10));
volume = ifft2(spectra)

Using ifft2 with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how ifft2 changes the result.

Run a small ifft2 example, explain the result, then change one input and compare the output.

FAQ

Is ifft2(X) equivalent to ifft(ifft(X, [], 1), [], 2)?⌄

Yes. RunMat literally performs two sequential 1-D inverse transforms so the behaviour matches MATLAB exactly.

How do zero-length sizes behave?⌄

Passing 0 for either transform length produces an output with zero elements along that dimension, just like MATLAB.

Can I mix [] with explicit sizes (e.g., ifft2(X, [], 64))?⌄

Yes. [] leaves that dimension unchanged while the other argument controls padding or truncation.

What does the 'symmetric' flag do?⌄

It tells RunMat to coerce the result to real values, assuming the spectrum is conjugate-symmetric. Imaginary parts are dropped.

What happens when the input is real-valued?⌄

RunMat promotes the data to complex with zero imaginary parts before applying the inverse. The output can still be coerced to real with 'symmetric'.

Will ifft2 run on the GPU automatically?⌄

Yes when the input handle's owning provider exposes ifft_dim and returns valid fresh results. An explicit unsupported-hook response falls back through an exact owner download; provider failures or malformed results are not silently gathered away.

Does ifft2 normalise the result?⌄

Yes. The builtin divides by the product of the transform lengths so that ifft2(fft2(X)) reproduces X.

Can I pass gpuArray size vectors or symmetry flags?⌄

No. Length arguments must be host scalars or vectors, and the symmetry flag must be a host string, mirroring MATLAB’s restrictions.

How are higher-dimensional arrays handled?⌄

Transformations are applied to every 2-D slice defined by the first two dimensions; trailing dimensions are preserved unchanged.

Does 'nonsymmetric' change the result?⌄

It simply states the default behaviour (return complex outputs) but is accepted for MATLAB compatibility.

Related Math functions

Fft

fft · fft2 · fftn · fftshift · ifft · ifftn · ifftshift

Elementwise

abs · angle · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · typecast · uint16 · uint32 · uint8

Trigonometry

acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh

Reduction

all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · decomposition · eig · eigs · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref · vecnorm

Optim

coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimoptions · optimset · quad · secondordercone

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Symbolic

digits · int · limit · piecewise · sym · syms · vpa

Interpolation

griddedInterpolant · interp1 · interp1q · interp2 · pchip · ppval · spline

Discrete

lcm · primes

Ode

ode15s · ode23 · ode45

Poly

polyder · polyfit · polyint · polyval · roots

Open-source implementation

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

  • View the source for ifft2 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.

Getting started · Benchmarks · Pricing

Download RunMat

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

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How ifft2 works
  • GPU memory and residency
  • Examples
  • Reconstructing an image patch from its 2-D spectrum
  • Zero-padding before the inverse transform
  • Supplying transform lengths with a size vector
  • Forcing a real-valued result with 'symmetric'
  • Running ifft2 on gpuArray inputs
  • Recovering each slice of a volume
  • Using ifft2 with coding agents
  • FAQ
  • Related Math functions
  • Fft
  • Elementwise
  • Trigonometry
  • Reduction
  • Structure
  • Signal
  • Rounding
  • Factor
  • Solve
  • Optim
  • Ops
  • Symbolic
  • Interpolation
  • Discrete
  • Ode
  • Poly
  • Open-source implementation
  • About RunMat