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

isinf — Test infinite values element-wise in MATLAB and RunMat.

mask = isinf(x) returns a logical mask indicating which elements are +Inf or -Inf. Output shape and type handling follow MATLAB semantics.

Syntax

tf = isinf(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input value to test for infinities.

Returns

NameTypeDescription
tfLogicalArrayLogical mask for infinite elements.

Errors

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

How isinf 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 +Inf or -Inf.
  • Complex inputs report true when either the real or the imaginary component is infinite.
  • Logical inputs return false because logical values (0 or 1) are finite by construction.
  • Character arrays return logical arrays of zeros (characters map to finite code points).
  • String arrays return logical arrays of zeros, mirroring MATLAB behavior.
  • string scalars (string objects) return a logical scalar false.
  • When the input is a gpuArray, RunMat keeps the computation on the device if the active acceleration provider implements the logical_isinf hook; otherwise the runtime gathers the data back to the host automatically.

Does RunMat run isinf on the GPU?

When RunMat Accelerate is active, isinf looks for the provider hook logical_isinf. Providers that implement the hook execute the infinity 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

Checking if a scalar is infinite

result = isinf(1/0)

Expected output:

result =
     1

Detecting infinities after division by zero

A = [1 0; 2 0];
quot = 1 ./ A;
mask = isinf(quot)

Expected output:

mask =
  2×2 logical array
     0     1
     0     1

Flagging infinite components of a complex array

Z = [Inf+0i 1-Inf*1i 2+3i];
mask = isinf(Z)

Expected output:

mask =
  1×3 logical array
     1     1     0

Applying isinf to character data

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

Expected output:

mask =
  1×3 logical array
     0     0     0

Running isinf directly on the GPU

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

Expected output:

mask =
  1×3 logical array
     0     1     1

Using isinf with coding agents

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

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

FAQ

Does isinf treat NaN values as infinite?⌄

No. isinf only reports true for IEEE positive or negative infinity. NaN values return false, so you can combine isinf with isnan when you need to distinguish between the two.

What does isinf return for logical inputs?⌄

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

How does isinf handle complex numbers?⌄

It returns true when either the real or the imaginary component is infinite, matching MATLAB semantics.

Does isinf move data between the CPU and GPU?⌄

Only when necessary. If the selected provider implements logical_isinf, all work stays on the GPU. Otherwise, RunMat gathers the tensor to the host, computes the result, and delivers a logical array.

What happens with string or character inputs?⌄

String scalars return false. Character arrays and string arrays return logical zeros with the same shape as the input.

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

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 · isfinite · isgpuarray · 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 isinf is executed, line by line, in Rust.

  • View the source for isinf 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 isinf works
  • Does RunMat run isinf on the GPU?
  • GPU memory and residency
  • Examples
  • Checking if a scalar is infinite
  • Detecting infinities after division by zero
  • Flagging infinite components of a complex array
  • Applying isinf to character data
  • Running isinf directly on the GPU
  • Using isinf with coding agents
  • FAQ
  • Related Logical functions
  • Tests
  • Bit
  • Rel
  • Logical
  • Open-source implementation
  • About RunMat