empty — Create an empty array of a specified class.
ClassName.empty creates a 0-by-0 empty array of the receiver class. Size arguments can specify other empty shapes, but at least one normalized dimension must be zero.
Syntax
A = ClassName.empty
A = ClassName.empty(sz1, ..., szN)
A = ClassName.empty(sizeVector)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
dimensions | SizeArg | Variadic | — | Integer scalar dimensions; at least one dimension must be zero. |
sizeVector | SizeArg | Yes | — | Row vector of integer dimensions; at least one dimension must be zero. |
Returns
| Name | Type | Description |
|---|---|---|
A | Any | Empty array preserving the receiver class. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:empty:InvalidSize | Size arguments are not integer-valued numeric scalars or one row size vector. | empty: invalid size arguments |
RunMat:empty:NonEmptyShape | Every normalized dimension is nonzero. | empty: at least one dimension must be zero |
RunMat:empty:UnsupportedClass | The selected shorthand class cannot be represented as a shaped empty value. | empty: unsupported output class |
RunMat:empty:Internal | The empty value cannot be assembled. | empty: internal error |
How empty works
- RunMat registers class-qualified forms for
int8.empty,int16.empty,int32.empty,int64.empty,uint8.empty,uint16.empty,uint32.empty, anduint64.empty. - All eight integer classes are accepted for scalar dimension controls and row size vectors. Values are decoded from authoritative integer storage without conversion through double.
- Signed negative dimensions become zero. Nonnegative dimensions must be integer-valued and within the platform size range.
- A single scalar dimension requests a square shape. A size-vector argument must be a row vector; column vectors reject.
- Trailing singleton dimensions after dimension two are removed. At least one remaining dimension must be zero.
- Integer outputs contain exact empty
IntegerStorageof the receiver class. - The global
empty(...)shorthand and its trailing typename selector are RunMat-only extensions. MATLAB-compatible mode requires class-qualified syntax. - The former global
"like"shorthand is not retained because it did not inherit output class and is not part of the documented class-static surface. - User-defined and general object-class empty arrays require broader class-array storage and static-method dispatch support.
GPU memory and residency
Integer class-static forms construct host empty storage. Resident numeric size controls are accepted only in RunMat mode and reject before provider access when extensions are disabled.
Examples
Create an empty unsigned integer array
A = uint8.emptyExpected output:
`A` is a 0-by-0 uint8 array with authoritative uint8 storage.Create an empty integer array with a nonzero second dimension
A = int16.empty(int64(0), uint64(5))Expected output:
`A` is a 0-by-5 int16 array.Use a row size vector
A = uint64.empty(uint32([0 0 6]))Expected output:
`A` is a 0-by-0-by-6 uint64 array.Using empty with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how empty changes the result.
Run a small empty example, explain the result, then change one input and compare the output.
FAQ
Does the class come from a size argument?⌄
No. In MATLAB-compatible syntax the receiver in ClassName.empty determines the output class. Integer size arguments are structural controls only.
Are wide uint64 dimensions converted through double?⌄
No. Host integer controls are decoded exactly from integer storage and checked against the platform size range.
Can empty create a nonempty array?⌄
No. After signed-negative clamping and trailing-singleton normalization, at least one dimension must be zero.
Can I call empty as a global function?⌄
Only in RunMat mode. The global shorthand is explicitly compatibility-gated; portable MATLAB-compatible code uses ClassName.empty.
Related Array functions
Creation
colon · createArray · eye · false · full · inf · linspace · logspace · magic · meshgrid · nan · nchoosek · ndgrid · nonzeros · ones · peaks · perms · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · zeros
Grouping
accumarray · combinations · discretize · findgroups · groupcounts · grp2idx · splitapply
Sorting Sets
argsort · intersect · ismember · ismembertol · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how empty is executed, line by line, in Rust.
- View the source for empty 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.