RunMat
GitHub

qammod — Map integers to QAM constellation points in MATLAB and RunMat.

qammod(X, M) maps integer symbols X to complex QAM constellation points for modulation order M. Gray, binary, and custom symbol-ordering behavior follow MATLAB semantics.

Syntax

qammod(X, M)

How qammod works

  • X must contain finite integer values in the inclusive range [0, M-1].
  • M must be a power-of-two integer greater than one.
  • Square QAM orders such as 4, 16, 64, and 256 use symmetric odd integer amplitudes with minimum distance two.
  • Non-square power-of-two orders use a rectangular grid with the larger dimension on the in-phase axis.
  • The default 'gray' order applies Gray coding independently to the in-phase and quadrature grid indexes.
  • 'UnitAveragePower', true scales the complete constellation so its average power is one.
  • 'OutputDataType', 'single' rounds the real and imaginary samples through single precision before returning the host complex tensor.
  • 'PlotConstellation', true and InputType='bit' are not implemented yet.

Does RunMat run qammod on the GPU?

RunMat's current accelerator API stores real-valued GPU buffers. Since qammod necessarily produces complex-valued samples, the GPU-aware implementation preserves correctness by gathering device input and producing a ComplexTensor on the host.

The registered GPU metadata advertises the supported input scalar classes and the provider hook name future accelerators can use once complex GPU outputs are represented.

GPU memory and residency

The builtin declares GatherImmediately residency. A gpuArray input is downloaded once through the dispatcher and then mapped to complex host output.

Examples

Default 16-QAM Gray mapping

y = qammod(0:15, 16)

Expected output:

y = [-3+3i -3+1i -3-3i -3-1i -1+3i -1+1i -1-3i -1-1i 3+3i 3+1i 3-3i 3-1i 1+3i 1+1i 1-3i 1-1i]

Binary symbol ordering

y = qammod(0:4, 16, 'bin')

Expected output:

y = [-3+3i -3+1i -3-1i -3-3i -1+3i]

Unit-average-power 16-QAM

y = qammod(0:15, 16, 'UnitAveragePower', true);
mean(abs(y).^2)

Expected output:

ans = 1

Using qammod with coding agents

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

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

FAQ

Does qammod execute on the GPU?

It accepts gpuArray inputs, but the current runtime gathers them to host memory and returns a host ComplexTensor because complex GPU tensor handles are not yet part of RunMat's value model.

Is bit input supported?

Not in this first implementation. Use integer symbols or convert bit groups to integer symbols before calling qammod.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how qammod 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.