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. Documented integer data through 32 bits produces double output. Host int64 and uint64 data and wide typed controls are exactness-checked RunMat extensions.
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 |
RunMat:ifft:ProviderIntegrity | The provider returns ownership, shape, or physical metadata inconsistent with the request. | ifft: provider integrity 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.- Documented integer data (
int8throughint32anduint8throughuint32) crosses once into the double transform domain and returns double numeric class; the symmetry flag changes complexity, not numeric class. - Host
int64anduint64data is available only in RunMat extension mode and must be exactly representable as double. Resident wide-integer data rejects before gather because no exact provider transform is available. - Typed
int64anduint64length or dimension controls are independently gated RunMat extensions and are parsed from exact integer storage. - Empty inputs and dimensions larger than the rank of
Xmirror MATLAB behaviour.
Does RunMat run ifft on the GPU?
For floating input, RunMat asks the input owner for ifft_dim and accepts only a fresh, nonaliased output with the expected device, shape, complex storage, precision, and ownership. Provider execution or contract failures are terminal; only the exact unsupported-hook response selects host fallback.
The symmetric form safely downloads the validated inverse-FFT result, extracts the real component in its native class, and restores a fresh real handle when the owner preserves that class. This avoids relying on provider-specific physical complex-buffer shapes.
Zero-length, logical, and documented resident integer inputs use the exact host transform path. F32 floating inputs preserve single precision; integer and logical inputs produce double output and stay on the host when an F32-only provider cannot represent that class.
GPU memory and residency
RunMat resolves execution and fallback through the provider that owns the input handle. Internal downloads do not change the source handle's class metadata. Host fallback results return to the owner only when its physical precision preserves the required output class; documented integer and logical inputs therefore remain double host results on an F32-only owner.
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?⌄
When the input owner exposes a compatible ifft_dim kernel, nonsymmetric results remain resident after provider metadata and ownership validation. Unsupported hooks fall back through an internal owner download. RunMat restores the result to that owner when its physical precision matches the required output class; otherwise it returns the correctly typed host result instead of relabeling lower-precision storage.
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 · 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
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
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.