isnumeric — Return true when a value is stored as numeric data (real or complex).
tf = isnumeric(x) returns a logical scalar that is true when x stores numeric data and false otherwise. Numeric data includes doubles, singles, integers, and complex numbers, as well as dense numeric arrays that live on the CPU or GPU.
How isnumeric works in RunMat
- Every built-in numeric class (
double,single, signed/unsigned integer types) returnstrue, including complex scalars. - Real and complex numeric arrays return
trueregardless of dimensionality or residency on the CPU or GPU. gpuArrayvalues rely on provider metadata: numeric handles returntrue, while logical masks constructed on the GPU returnfalse.- Logical values, characters, strings, tables, cell arrays, structs, objects, and function handles return
false. - The result is always a logical scalar.
How isnumeric runs on the GPU
When RunMat Accelerate is active, isnumeric first checks provider metadata via the logical_islogical hook to determine whether a gpuArray handle was created as a logical mask. Providers that supply the hook can answer the query without copying data back to the host. When the hook is absent, RunMat consults its residency metadata and only gathers the value to host memory when the residency tag is missing, ensuring the builtin always succeeds.
GPU memory and residency
You generally do **not** need to call gpuArray manually. RunMat's auto-offload planner keeps numeric tensors on the GPU across fused expressions whenever that improves performance. Explicit gpuArray and gather calls remain available for compatibility with MATLAB scripts that manage residency themselves.
Examples
Checking if a scalar double is numeric
tf = isnumeric(42)Expected output:
tf =
1Detecting numeric matrices
A = [1 2 3; 4 5 6];
tf = isnumeric(A)Expected output:
tf =
1Testing complex numbers for numeric storage
z = 1 + 2i;
tf = isnumeric(z)Expected output:
tf =
1Logical arrays are not numeric
mask = logical([1 0 1]);
tf = isnumeric(mask)Expected output:
tf =
0Character vectors and strings return false
chars = ['R' 'u' 'n'];
name = "RunMat";
tf_chars = isnumeric(chars);
tf_string = isnumeric(name)Expected output:
tf_chars =
0
tf_string =
0Evaluating gpuArray inputs
G = gpuArray(rand(4));
mask = G > 0.5;
tf_numeric = isnumeric(G);
tf_mask = isnumeric(mask)Expected output:
tf_numeric =
1
tf_mask =
0FAQ
Does isnumeric ever return an array?
No. The builtin always returns a logical scalar, even when the input is an array.
Are complex tensors considered numeric?
Yes. Real and complex tensors both return true, matching MATLAB semantics.
Does isnumeric gather GPU data back to the host?
Only when residency metadata is unavailable. Providers that expose type metadata let RunMat answer the query without host↔device transfers.
Do logical masks return true?
No. Logical scalars and logical arrays return false. Use islogical if you need to detect logical storage explicitly.
What about character vectors or string arrays?
They return false, just like in MATLAB. Characters and strings are text types rather than numeric arrays.
Do cell arrays or structs ever count as numeric?
No. Containers and objects always return false.
Is there a difference between CPU and GPU numeric arrays?
No. Both host and device numeric arrays return true; only logical GPU handles report false.
Related functions to explore
These functions work well alongside isnumeric. Each page has runnable examples you can try in the browser.
islogical, isreal, isfinite, gpuArray, gather, isgpuarray, isinf, isnan
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how isnumeric works, line by line, in Rust.
- View isnumeric.rs on GitHub
- Learn how the 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 — faster, on any GPU, with no license required.
- Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
- Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
- A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.