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
varargin- Type
Any- Required
- Variadic
- Description
- Input values to distribute.
Returns
varargout- Type
Any- Description
- Distributed output values.
Returned values from deal depend on how many outputs the caller requests.
Errors
RunMat:deal:InputOutputCountMismatch- When
- The call has multiple inputs and the requested output count differs from the input count, or has no input and a nonzero output count.
- Message
deal: the number of outputs must match the number of inputs unless there is exactly one input
Behavior
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.
Syntax
[B1,...,Bn] = deal(A1,...,An)
[B1,...,Bn] = deal(A)
Outputs preserve their corresponding input values.
Multiple inputs require the same number of outputs.
One input is replicated to every requested output.
Residency
deal performs no numeric computation. RunMat can pass resident values through without gather behind an explicit compatibility gate.
deal is output-list construction and is not fused.
When its RunMat-only extension is enabled, deal preserves a resident handle and its owner without gather, upload, allocation, or provider dispatch.
Execution
Focused tests cover matching distribution, single-input replication, count errors, all eight exact integer storage classes, zero-output behavior, and pre-access resident gating.
No numerical kernel, provider access, filesystem access, callback, or suspension occurs. Nested values and handles retain their ownership and alias identity. The internal OutputList carrier remains at the current builtin ABI; requested and discarded outputs are validated before copying.
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.Compile exact integer distribution
wide = uint64(9007199254740992) + uint64(1);
[left, right] = deal(wide);
[~, selected] = deal(uint8(3), wide);
deal(wide);Catch a compiled output-count error once
global dealCalls; dealCalls = 0; caught = false;
try
operation = @deal;
[a,b,c] = operation(nextDealInput(), uint16(8));
catch failure
caught = strcmp(failure.identifier, 'RunMat:deal:InputOutputCountMismatch');
end
assert(caught && dealCalls == 1);
function value = nextDealInput()
global dealCalls; dealCalls = dealCalls + 1;
value = uint64(9007199254740992) + uint64(1);
endUsing 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.
Source you can read
Every RunMat function's source is public. 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 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.