deal — Distribute input values to requested outputs.
[B1,...,Bn] = deal(A1,...,An) copies matching inputs positionally. [B1,...,Bn] = deal(A) copies one input to every requested output.
Syntax
[varargout] = deal(varargin)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
varargin | Any | Variadic | — | Input values to distribute. |
Returns
| Name | Type | Description |
|---|---|---|
varargout | Any | Distributed output values. |
Returned values from deal depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:deal:InputOutputCountMismatch | The call has multiple inputs and the requested output count differs from the input count, or has no input and a nonzero output count. | deal: the number of outputs must match the number of inputs unless there is exactly one input |
How deal works
- With multiple inputs, the number of requested outputs must equal the number of inputs.
- With one input, any requested output count receives the same value.
- Values pass through structurally without numeric conversion, preserving integer class, shape, exact values, and handle identity.
- Resident pass-through is a RunMat-only extension because the current public page documents GPU code generation but not interactive GPU Arrays. The gate runs without gather or provider access.
- RunMat does not retain the former one-output cell-packing behavior; use a cell-array literal when a packed cell row is intended.
GPU memory and residency
When its RunMat-only extension is enabled, deal preserves a resident handle and its owner without gather, upload, allocation, or provider dispatch.
Examples
Distribute matching values
[a,b] = deal(int64(7), uint64(9))Expected output:
a is int64(7) and b is uint64(9).Replicate one value
u = uint64(9007199254740992) + uint64(1); [a,b,c] = deal(u)Expected output:
All three outputs preserve the exact uint64 value.How RunMat validates deal
Focused tests cover matching distribution, single-input replication, count errors, all eight exact integer storage classes, zero-output behavior, and pre-access resident gating.
- Implementation: `crates/runmat-runtime/src/builtins/common/deal.rs`
See Correctness & Trust for the full methodology and coverage table.
Using deal with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how deal changes the result.
Run a small deal example, explain the result, then change one input and compare the output.
FAQ
Does deal convert integer inputs to double?⌄
No. It copies values without arithmetic or class conversion.
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how deal is executed, line by line, in Rust.
- View the source for deal 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.