RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.2, Nov 26, 2026 ·

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

X
Type
Any
Required
Yes
Description
Input spectrum or signal.
SIZE
Type
NumericArray
Required
No
Default
[]
Description
Scalar N or two-element [M N] size vector.
M
Type
NumericScalar
Required
No
Default
[]
Description
Output row count for transform.
N
Type
NumericScalar
Required
No
Default
[]
Description
Output column count for transform.
symflag
Type
StringScalar
Required
No
Default
"nonsymmetric"
Description
Symmetry flag: "symmetric" or "nonsymmetric".
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

Y
Type
NumericArray
Description
2-D inverse FFT output.
NameTypeDescription
YNumericArray2-D inverse FFT output.

Errors

RunMat:ifft2:ArgCount
When
More than four input arguments are supplied.
Message
ifft2: invalid argument count
RunMat:ifft2:InvalidLength
When
Length/size arguments are invalid.
Message
ifft2: invalid transform length argument
RunMat:ifft2:InvalidSizeVector
When
Single SIZE argument is invalid.
Message
ifft2: invalid size vector argument
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

Provider and fusion contract

The provider hook advertises f32 and f64 floating precision with MATLAB-style input shape semantics; integer and logical behavior follows the separate documented conversion or exact-reordering rules.

This operation is a fusion boundary, not an elementwise or reduction kernel. No fused FFT kernel is advertised, and provider launch details remain internal.

Behavior

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 execution

Uses the input handle's owning provider for two validated ifft_dim passes. Only an explicit unsupported-hook response selects exact host fallback; malformed, aliased, or wrong-owner results are terminal and safely released.

GPU 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

X = [1 2; 3 4];
F = fft2(X);
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 · besselj · bsxfun · complex · conj · double · eps · erf · erfcinv · exp · expm1 · flintmax · gamma · gammaln · heaviside · hypot · imag · int16 · int32 · int64 · int8 · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · times · typecast · uint16 · uint32 · uint64 · uint8

Optim

acceptancesa · annealingboltz · annealingfast · coneprog · crossoverarithmetic · crossoverheuristic · crossoverintermediate · crossoverlaplace · crossoverscattered · crossoversinglepoint · crossovertwopoint · eqnproblem · EquationProblem.solve · EquationProblem.subsasgn · EquationProblem.subsref · evaluate · fgoalattain · fitscalingprop · fitscalingrank · fitscalingshiftlinear · fitscalingtop · fminbnd · fmincon · fminimax · fminsearch · fminunc · fseminf · fsolve · fzero · ga · gacreationlinearfeasible · gacreationnonlinearfeasible · gacreationsobol · gacreationuniform · gacreationuniformint · gaplotbestf · gaplotbestindiv · gaplotdistance · gaplotexpectation · gaplotgenealogy · gaplotmaxconstr · gaplotrange · gaplotscorediversity · gaplotscores · gaplotselection · gaplotstopping · integerConstraint · integral · intlinprog · linprog · lsqcurvefit · lsqlin · LsqlinWarmStart.subsasgn · LsqlinWarmStart.subsref · lsqnonlin · lsqnonneg · mutationadaptfeasible · mutationgaussian · mutationpositivebasis · mutationpower · mutationuniform · optimexpr · optimget · OptimizationConstraint.evaluate · OptimizationConstraint.subsasgn · OptimizationConstraint.subsref · OptimizationExitflag.double · OptimizationExitflag.eq · OptimizationExitflag.ne · OptimizationExitflag.string · OptimizationExpression.acos · OptimizationExpression.acosh · OptimizationExpression.acot · OptimizationExpression.acoth · OptimizationExpression.acsc · OptimizationExpression.acsch · OptimizationExpression.asec · OptimizationExpression.asech · OptimizationExpression.asin · OptimizationExpression.asinh · OptimizationExpression.atan · OptimizationExpression.atanh · OptimizationExpression.cat · OptimizationExpression.cos · OptimizationExpression.cosh · OptimizationExpression.cot · OptimizationExpression.coth · OptimizationExpression.csc · OptimizationExpression.csch · OptimizationExpression.ctranspose · OptimizationExpression.cumprod · OptimizationExpression.cumsum · OptimizationExpression.diag · OptimizationExpression.diff · OptimizationExpression.dot · OptimizationExpression.eq · OptimizationExpression.evaluate · OptimizationExpression.exp · OptimizationExpression.ge · OptimizationExpression.horzcat · OptimizationExpression.ldivide · OptimizationExpression.le · OptimizationExpression.log · OptimizationExpression.mean · OptimizationExpression.minus · OptimizationExpression.mldivide · OptimizationExpression.mpower · OptimizationExpression.mrdivide · OptimizationExpression.mtimes · OptimizationExpression.norm · OptimizationExpression.plus · OptimizationExpression.power · OptimizationExpression.prod · OptimizationExpression.rdivide · OptimizationExpression.reshape · OptimizationExpression.sec · OptimizationExpression.sech · OptimizationExpression.sin · OptimizationExpression.sinh · OptimizationExpression.sqrt · OptimizationExpression.subsasgn · OptimizationExpression.subsref · OptimizationExpression.sum · OptimizationExpression.tan · OptimizationExpression.tanh · OptimizationExpression.times · OptimizationExpression.trace · OptimizationExpression.transpose · OptimizationExpression.uminus · OptimizationExpression.uplus · OptimizationExpression.vertcat · OptimizationExpression.zeros · OptimizationExpression.zerosLike · OptimizationProblem.solve · OptimizationProblem.subsasgn · OptimizationProblem.subsref · OptimizationVariable.subsasgn · OptimizationVariable.subsref · optimoptions · optimplotconstrviolation · optimplotfirstorderopt · optimplotfunccount · optimplotfval · optimplotfvalconstr · optimplotmilp · optimplotstepsize · optimplotx · optimproblem · optimset · optimvar · optimwarmstart · particleswarm · patternsearch · psplotbestf · psplotbestx · psplotfuncount · psplotmaxconstr · psplotmeshsize · pswcreationuniform · pswplotbestf · quad · quadprog · QuadprogWarmStart.subsasgn · QuadprogWarmStart.subsref · saplotbestf · saplotbestx · saplotf · saplotstopping · saplottemperature · saplotx · savemilpsolutions · secondordercone · selectionremainder · selectionroulette · selectionstochunif · selectiontournament · selectionuniform · simulannealbnd · solve · surrogateopt · surrogateoptplot · temperatureboltz · temperatureexp · temperaturefast

Trigonometry

acos · acosd · acosh · acotd · acscd · asecd · asin · asind · asinh · atan · atan2 · atan2d · atand · 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

Bitwise

bitand · bitcmp · bitget · bitor · bitset · bitshift · bitxor · swapbytes

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 · decomposition.ctranspose · decomposition.mldivide · decomposition.mrdivide · decomposition.mtimes · decomposition.rdivide · decomposition.subsref · decomposition.times · decomposition.uminus · decomposition.uplus · eig · eigs · gmres · ichol · ilu · lu · ordeig · ordqz · ordschur · pcg · qr · qz · rsf2csf · schur · svd

Solve

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

Ops

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

Symbolic

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

Discrete

factor · factorial · gcd · isprime · lcm · primes

Interpolation

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

Integer Division

idivide

Ode

ode15s · ode23 · ode45 · odeset

Poly

poly · polyder · polyfit · polyint · polyval · roots

Source you can read

Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Provider and fusion contract
  • Behavior
  • GPU execution
  • GPU 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
  • Optim
  • Trigonometry
  • Reduction
  • Structure
  • Bitwise
  • Signal
  • Rounding
  • Factor
  • Solve
  • Ops
  • Symbolic
  • Discrete
  • Interpolation
  • Integer Division
  • Ode
  • Poly
  • Source you can read
  • About RunMat