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
    • argsort
    • intersect
    • ismember
    • ismembertol
    • issorted
    • issortedrows
    • setdiff
    • setxor
    • sort
    • sortrows
    • union
    • unique

ismembertol — Test numeric membership within tolerance in MATLAB and RunMat.

ismembertol(A, B) returns logical membership flags for real numeric values in A that are within tolerance of values in B. Optional outputs return first or all matching one-based indices into B.

Syntax

LIA = ismembertol(A, B)
LIA = ismembertol(A, B, tol, Name, Value)
[LIA, LocB] = ismembertol(A, B)
[LIA, LocB] = ismembertol(A, B, tol, Name, Value)

Inputs

NameTypeRequiredDefaultDescription
ANumericArrayYes—Query values or rows.
BNumericArrayYes—Reference values or rows.
tolNumericScalarNo1e-12 for double, 1e-6 for singleRelative tolerance.
Name,ValueAnyVariadic—Name-value options: ByRows, DataScale, OutputAllIndices.

Returns

NameTypeDescription
LIALogicalArrayLogical mask over A.
LocBAnyFirst or all matching indices into B.

Returned values from ismembertol depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:ismembertol:InvalidInputA or B is not a supported real full numeric input.ismembertol: inputs must be real full numeric arrays
RunMat:ismembertol:InvalidArgumentTolerance or name-value arguments are malformed.ismembertol: invalid argument
RunMat:ismembertol:RowsColumnMismatchByRows is true and A/B column counts differ.ismembertol: inputs must have the same number of columns when ByRows is true
RunMat:ismembertol:InternalInternal conversion or allocation fails.ismembertol: internal error

How ismembertol works

  • Without an explicit tolerance, RunMat uses MATLAB-compatible defaults: 1e-12 for double inputs and 1e-6 when either input is single precision.
  • Element comparisons use abs(A-B) <= tol * max(abs([A(:); B(:)])) unless DataScale is supplied.
  • DataScale, when scalar, changes the tolerance test to abs(A-B) <= tol * DataScale.
  • ByRows, true compares complete rows and returns outputs of size size(A,1) x 1; A and B must have the same number of columns.
  • In row mode, vector DataScale supplies one scale per column. A scale of Inf ignores that column during matching.
  • The optional second output LocB contains the first one-based index in B for each match and 0 when absent.
  • OutputAllIndices, true makes LocB a cell array whose cells contain all matching one-based indices, or [0] when no match exists.
  • NaN values do not match. Exact equalities, including equal infinities, match before tolerance subtraction is considered.
  • Complex, sparse, string, character, cell, struct, and object inputs are rejected. The documented host data and tolerance domains are single and double; RunMat mode additionally accepts host integer/logical data and typed integer/logical tolerance controls through declared compatibility extensions.

Does RunMat run ismembertol on the GPU?

ismembertol is registered as a sink builtin. When either input tensor lives on the GPU the runtime gathers authoritative typed storage to host memory and performs tolerance matching there.

Documented ordinary logical and double-index outputs are restored to the first resident input handle's owning provider. Integer gpuArray inputs through 32 bits retain their documented support across the fallback.

Resident 64-bit integer input and enabled ByRows or OutputAllIndices are RunMat-only extensions checked before gather. The extended all-indices cell result remains host materialized because the public GPU form excludes that output.

Examples

Testing approximate membership with default scaling

A = [0.1 1e10];
B = [0.1 + 1e-14, 1e10 + 5e-3];
LIA = ismembertol(A, B)

Expected output:

LIA =
  1x2 logical array
   1   1

Returning first matching indices

A = [1 2 4];
B = [2.01 2.02 4.2];
[LIA, LocB] = ismembertol(A, B, 0.05)

Expected output:

LIA =
  1x3 logical array
   0   1   1
LocB =
     0     1     3

Using absolute tolerance with DataScale

A = 1e10;
B = 1e10 + 5e-3;
LIA = ismembertol(A, B, 1e-6, 'DataScale', 1)

Expected output:

LIA =
     0

Comparing rows and ignoring one column

A = [0 0.5; 10 20];
B = [0.05 999; 10.2 -999];
[LIA, LocB] = ismembertol(A, B, 0.1, 'ByRows', true, 'DataScale', [1 Inf])

Expected output:

LIA =
  2x1 logical array
   1
   0
LocB =
     1
     0

Returning all matching locations

A = 2;
B = [1.99 2.01 9.5];
[LIA, LocB] = ismembertol(A, B, 0.01, 'OutputAllIndices', true)

Expected output:

LIA =
     1
LocB =
  1x1 cell array
    {[1; 2]}

Using gpuArray inputs

G = gpuArray([1; 2]);
H = gpuArray([1 + 1e-13; 3]);
LIA = ismembertol(G, H)

Expected output:

LIA =
  2x1 logical array
   1
   0

Using ismembertol with coding agents

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

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

FAQ

How is the default tolerance chosen?⌄

Double inputs use 1e-12. If either input is single precision, RunMat uses 1e-6.

Does ismembertol support string or cell inputs like ismember?⌄

No. MATLAB's tolerance membership operation is numeric; RunMat accepts real full numeric and logical inputs only.

What does OutputAllIndices change?⌄

The second output becomes a cell array. Each cell contains every one-based index in B within tolerance of the corresponding element or row of A, or [0] when no match exists.

Can DataScale be a vector?⌄

Only when ByRows is true. Each vector element scales the tolerance for the corresponding column; Inf ignores that column.

Do NaN values match each other?⌄

No. NaN does not match any value, including another NaN, for ismembertol.

Will ismembertol run on the GPU automatically?⌄

Documented gpuArray input includes integer classes through 32 bits but excludes 64-bit integers, ByRows, and OutputAllIndices. RunMat preserves those additional forms behind explicit compatibility gates.

Related Array functions

Sorting Sets

argsort · intersect · ismember · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique

Grouping

accumarray · combinations · discretize · findgroups · groupcounts · grp2idx · splitapply

Shape

blkdiag · cat · circshift · diag · flip · fliplr · flipud · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · squeeze · toeplitz · tril · triu · vertcat

Creation

colon · createArray · empty · eye · false · full · inf · linspace · logspace · magic · meshgrid · nan · nchoosek · ndgrid · nonzeros · ones · peaks · perms · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · zeros

Indexing

find · ind2sub · sub2ind

Introspection

iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size

Open-source implementation

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

  • View the source for ismembertol 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 ismembertol works
  • Does RunMat run ismembertol on the GPU?
  • Examples
  • Testing approximate membership with default scaling
  • Returning first matching indices
  • Using absolute tolerance with DataScale
  • Comparing rows and ignoring one column
  • Returning all matching locations
  • Using gpuArray inputs
  • Using ismembertol with coding agents
  • FAQ
  • Related Array functions
  • Sorting Sets
  • Grouping
  • Shape
  • Creation
  • Indexing
  • Introspection
  • Open-source implementation
  • About RunMat