allfinite — Return true when every element of the input is finite.

tf = allfinite(A) returns a scalar logical indicating whether every element of A is finite. It is equivalent to applying isfinite to the whole input and reducing the mask with all(...,'all').

Syntax

tf = allfinite(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYesInput value to test for finite elements.

Returns

NameTypeDescription
tfLogicalArrayTrue when every element of the input is finite.

Errors

IdentifierWhenMessage
RunMat:allfinite:InvalidInputInput is not numeric, logical, char, or string.allfinite: expected numeric, logical, char, or string input
RunMat:allfinite:InternalErrorA GPU provider, gather, download, or internal shape operation fails.allfinite: internal error

How allfinite works

  • Numeric scalars return true for finite values and false for NaN or Inf.
  • Numeric arrays return a scalar logical over all elements; empty numeric arrays return true.
  • Complex inputs return true only when every real and imaginary component is finite.
  • Sparse inputs inspect stored nonzero values; implicit zeros are finite.
  • Logical and character arrays return true.
  • String scalars and nonempty string arrays return false; empty string arrays return true.
  • Cell arrays, structs, objects, and function handles are rejected with RunMat:allfinite:InvalidInput.

Does RunMat run allfinite on the GPU?

allfinite is a scalar predicate over the full input. gpuArray inputs use provider-side isfinite plus all reduction when available; the scalar logical result is returned on the CPU. Providers without those hooks fall back to host gather and reduction.

Examples

Check a finite matrix

tf = allfinite([1 2; 3 4])

Expected output:

tf =
     1

Detect nonfinite values

tf = allfinite([1 NaN Inf])

Expected output:

tf =
     0

Check complex values

tf = allfinite([1+2i 3-4i])

Expected output:

tf =
     1

Using allfinite with coding agents

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

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

FAQ

How is allfinite(A) different from isfinite(A)?

isfinite returns an element-wise logical mask. allfinite returns a single logical scalar for the whole input.

Are empty arrays all finite?

Yes. The result follows MATLAB-style all identity behavior: reducing an empty finite mask gives true.

How does allfinite handle complex numbers?

A complex value is finite only when both its real and imaginary components are finite.

Bit

and · bitand · bitor · bitshift · 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 allfinite is executed, line by line, in Rust.

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.