RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • allfinite
    • isfinite
    • isgpuarray
    • isinf
    • islogical
    • isnan
    • isnumeric
    • isreal
    • issparse

isfinite — Test finite values element-wise in MATLAB and RunMat.

mask = isfinite(x) returns a logical mask indicating which elements are finite (not NaN or ±Inf). Output shape and type handling follow MATLAB semantics.

Syntax

tf = isfinite(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input value to test for finiteness.

Returns

NameTypeDescription
tfLogicalArrayLogical mask for finite elements.

Errors

IdentifierWhenMessage
RunMat:isfinite:InvalidInputInput is not numeric, logical, char, or string.isfinite: expected numeric, logical, char, or string input
RunMat:isfinite:InternalErrorInternal mask-construction or gather path fails.isfinite: internal error

How isfinite works

  • Numeric scalars return a logical scalar (true/false).
  • Numeric arrays return a logical array of the same size, with true wherever the corresponding element is finite.
  • Complex inputs report true when both the real and imaginary components are finite.
  • Logical inputs return true because logical values (0 or 1) are finite by construction.
  • Character arrays return logical arrays of ones (characters map to finite Unicode code points).
  • String scalars return false; string arrays return logical arrays of zeros, mirroring MATLAB behavior.
  • When the input is a gpuArray, RunMat keeps the computation on the device if the active acceleration provider implements the logical_isfinite hook; otherwise the runtime gathers the data back to the host automatically.

Does RunMat run isfinite on the GPU?

When RunMat Accelerate is active, isfinite looks for the provider hook logical_isfinite. Providers that implement the hook execute the finite test entirely on the GPU, producing a logical gpuArray result without any host transfers. If the hook is absent, RunMat gathers the input tensor back to the CPU, computes the mask on the host, and returns a regular logical array so the builtin always succeeds.

GPU memory and residency

You usually do not need to call gpuArray explicitly. RunMat's auto-offload planner keeps tensors on the GPU across fused expressions when that improves performance. You can still seed residency manually with gpuArray for compatibility with MATLAB scripts or when you want fine-grained control over data movement.

Examples

Check if a scalar is finite

result = isfinite(42)

Expected output:

result =
     1

Create a finite mask for a numeric matrix

A = [1 NaN; Inf 4];
mask = isfinite(A)

Expected output:

mask =
  2×2 logical array
     1     0
     0     1

Identify finite components in a complex array

Z = [1+2i Inf+0i 3+NaNi];
mask = isfinite(Z)

Expected output:

mask =
  1×3 logical array
     1     0     0

Apply isfinite to character data

chars = ['R' 'u' 'n'];
mask = isfinite(chars)

Expected output:

mask =
  1×3 logical array
     1     1     1

Run isfinite directly on the GPU

G = gpuArray([1 -Inf 5]);
mask_gpu = isfinite(G);
mask = gather(mask_gpu)

Expected output:

mask =
  1×3 logical array
     1     0     1

Using isfinite with coding agents

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

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

FAQ

Does isfinite treat NaN or Inf values as finite?⌄

No. isfinite only returns true for values that are neither NaN nor infinite. Use isnan or isinf if you need to distinguish between those cases.

What does isfinite return for logical inputs?⌄

Logical inputs always produce true because logical values are limited to 0 or 1, which are finite.

How does isfinite handle complex numbers?⌄

It returns true only when both the real and imaginary components of the element are finite, matching MATLAB semantics.

What happens with string or character inputs?⌄

String scalars return false, and string arrays return logical zeros. Character arrays return logical ones because their Unicode code points are finite.

Can I fuse isfinite with other elementwise operations?⌄

Yes. The fusion planner treats isfinite as an elementwise operation, so expressions like isfinite(A ./ B) remain eligible for GPU fusion when the provider advertises support.

Is there a performance difference between isfinite, isnan, and isinf?⌄

Each predicate performs a single elementwise test. Performance is dominated by memory bandwidth, so they have comparable cost on both CPU and GPU.

Related Logical functions

Tests

allfinite · isgpuarray · isinf · islogical · isnan · isnumeric · isreal · issparse

Bit

and · bitand · bitcmp · bitget · bitor · bitset · bitshift · bitxor · not · or · xor

Rel

eq · ge · gt · isequal · isequaln · le · lt · ne

Logical

logical

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how isfinite is executed, line by line, in Rust.

  • View the source for isfinite 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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How isfinite works
  • Does RunMat run isfinite on the GPU?
  • GPU memory and residency
  • Examples
  • Check if a scalar is finite
  • Create a finite mask for a numeric matrix
  • Identify finite components in a complex array
  • Apply isfinite to character data
  • Run isfinite directly on the GPU
  • Using isfinite with coding agents
  • FAQ
  • Related Logical functions
  • Tests
  • Bit
  • Rel
  • Logical
  • Open-source implementation
  • About RunMat