RunMat
GitHub

isequal — Test array equality in MATLAB and RunMat.

isequal(A, B, ...) returns true when inputs have identical size, class, and element values. NaN handling and multi-input comparison semantics follow MATLAB behavior.

Syntax

tf = isequal(A, B, ...)

Inputs

NameTypeRequiredDefaultDescription
AAnyVariadicValues to compare (at least two).

Returns

NameTypeDescription
tfLogicalArrayTrue when all inputs are equal in size, class, and content.

Errors

IdentifierWhenMessage
RunMat:isequal:NotEnoughInputsFewer than two arguments are supplied.isequal: requires at least two input arguments
RunMat:isequal:InternalInternal gather/host normalization fails.isequal: internal error

How isequal works

  • isequal(A, B) compares two values for equality.
  • isequal(A, B, C, ...) compares all inputs against each other; returns true only if all are equal.
  • Arrays must have identical shape (size) to be equal.
  • Arrays must have matching data types (class) to be equal.
  • All corresponding elements must be identical for arrays to be equal.
  • NaN values are NOT equal to each other (NaN ~= NaN).
  • Empty arrays [] are equal to other empty arrays with the same shape.
  • Cell arrays are compared element-by-element recursively.
  • Structs are compared field-by-field.

Does RunMat run isequal on the GPU?

When comparing gpuArray inputs, isequal gathers all tensors to the host before performing the comparison. The result is a scalar logical value on the host.

GPU memory and residency

None. isequal gathers GPU tensors to the host for comparison. The result is always a host logical scalar.

Examples

Comparing two identical scalars

isequal(5, 5)

Expected output:

ans = logical
     1

Comparing two different scalars

isequal(5, 6)

Expected output:

ans = logical
     0

Comparing identical matrices

A = [1 2; 3 4];
B = [1 2; 3 4];
isequal(A, B)

Expected output:

ans = logical
     1

Comparing matrices with different shapes

A = [1 2 3];
B = [1; 2; 3];
isequal(A, B)

Expected output:

ans = logical
     0

Comparing multiple arrays at once

isequal([1 2], [1 2], [1 2])

Expected output:

ans = logical
     1

NaN values are not equal

isequal(NaN, NaN)

Expected output:

ans = logical
     0

Verifying that every cell starts with []

C = cell(2, 2);
isequal(C{1,1}, [], C{2,2}, [])

Expected output:

ans = logical
     1

Using isequal with coding agents

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

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

FAQ

How is isequal different from ==?

isequal returns a single logical value indicating whether all inputs are completely identical. The == operator performs element-wise comparison and returns an array of the same size as the inputs.

How does isequal handle NaN values?

NaN values are NOT considered equal. isequal(NaN, NaN) returns false. Use isequaln if you want NaN values to be treated as equal.

Can I compare more than two arrays?

Yes. isequal(A, B, C, ...) accepts any number of inputs and returns true only if all inputs are equal to each other.

Are empty arrays equal?

Empty arrays with the same shape are equal. For example, isequal([], []) returns true, and isequal(zeros(0,3), zeros(0,3)) returns true.

How are cell arrays compared?

Cell arrays are compared element-by-element. Each corresponding pair of cells must contain equal values for the cell arrays to be equal.

What happens with different data types?

Values of different classes are generally not equal. However, compatible numeric types (like double and single, or double and logical) may be compared after appropriate promotion.

Rel

eq · ge · gt · le · lt · ne

Bit

and · not · or · xor

Logical

logical

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how isequal 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.