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
    • eq
    • ge
    • gt
    • isequal
    • isequaln
    • le
    • lt
    • ne

lt — Compute element-wise less-than comparisons in MATLAB and RunMat.

lt(A, B) (or A < B) compares inputs element-wise and returns logical results. Numeric comparisons support exact mixed-integer handling, implicit expansion, and complex values ordered by their real parts.

Syntax

tf = lt(A, B)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Left operand.
BAnyYes—Right operand.

Returns

NameTypeDescription
tfLogicalArrayLogical less-than result.

Errors

IdentifierWhenMessage
RunMat:lt:InvalidInputOperands contain unsupported types or mixed numeric/string domains.lt: mixing numeric and string inputs is not supported
RunMat:lt:SizeMismatchOperands are not broadcast-compatible.lt: array sizes are not compatible for broadcasting
RunMat:gpu:ProviderOwnershipMismatchResident operands do not have one exact owning provider.lt: resident operands must have one exact owning provider
RunMat:lt:GpuUploadFailedAn explicitly resident logical result cannot be restored to its provider.lt: failed to preserve explicit gpuArray residency

How lt works

  • Numeric, logical, and character inputs compare element-wise using MATLAB's implicit expansion rules.
  • Character arrays compare by Unicode code point; mixing them with numeric arrays behaves like comparing numeric codes ('A' < 66).
  • String scalars and string arrays compare lexically; implicit expansion works across string dimensions.
  • Complex numeric inputs compare their real parts; imaginary components do not participate in the ordering.
  • Any numeric comparison involving NaN returns false.
  • Mixed numeric/string inputs raise type errors.
  • Sparse numeric comparisons are not implemented yet.

Does RunMat run lt on the GPU?

When both operands are GPU values on the same owner and the provider implements elem_lt, RunMat executes the comparison on-device and validates the logical result. Unsupported or mixed host/device cases gather for CPU comparison; explicit residency causes the result to be uploaded back to the originating owner, while automatic residency may remain on the host.

GPU memory and residency

When both operands share an exact GPU owner and the provider supports elem_lt, the logical result remains on that owner. Mixed owners are rejected. Host fallback from automatically resident operands may return a host logical result; if either operand is explicitly resident, fallback restores the result to that exact owner or returns an error.

Examples

Determine Whether One Scalar Is Less Than Another

flag = lt(17, 42)

Expected output:

flag =
     1

Filter Matrix Elements Below A Threshold

M = [1 2 3; 4 5 6];
mask = lt(M, 3)

Expected output:

mask =
  2×3 logical array
     1     1     0
     0     0     0

Apply Less-Than With Implicit Expansion

v = [1 3 5 7];
mask = lt(v, [2 6])

Expected output:

mask =
  1×4 logical array
     1     0     0     0

Compare Character Data To Numeric Codes

letters = ['A' 'B' 'C'];
isBeforeC = lt(letters, 67)

Expected output:

isBeforeC =
  1×3 logical array
     1     1     0

Compare String Arrays Lexicographically

names = ["alice" "charlie" "bob"];
earlier = lt(names, "bob")

Expected output:

earlier =
  1×3 logical array
     1     0     0

Run lt Directly On gpuArray Inputs

G1 = gpuArray([1 4 7]);
G2 = gpuArray([2 4 8]);
deviceResult = lt(G1, G2);
hostResult = gather(deviceResult)

Expected output:

deviceResult =
  1×3 gpuArray logical array
     1     0     1
hostResult =
  1×3 logical array
     1     0     1

Using lt with coding agents

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

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

FAQ

Does lt return logical values?⌄

Yes. Scalars return true or false. Arrays return logical arrays, and gpuArray inputs return gpuArray logical outputs.

How are NaN values treated?⌄

Any comparison involving NaN returns false, matching MATLAB behaviour.

Can I compare complex numbers with lt?⌄

Yes. RunMat compares the real components and ignores the imaginary components for ordering.

How are strings compared?⌄

String scalars and arrays compare lexicographically using Unicode code points, with full support for implicit expansion against scalar strings.

Are character vectors treated as numbers or text?⌄

Character arrays participate as numeric code points when compared to numeric inputs, and they are converted to strings when compared against string scalars or arrays.

Do I need to gather results manually after a GPU comparison?⌄

No. A supported same-owner comparison stays on that GPU. During fallback, automatic residency may return a host logical array, while explicit residency restores the result to the exact originating owner.

Does implicit expansion apply to string arrays?⌄

Yes. String arrays support MATLAB-style implicit expansion, so you can compare against scalar strings without manual replication.

Can I fuse lt inside GPU expressions?⌄

Yes. The builtin registers element-wise fusion metadata so the planner can fuse comparisons with surrounding GPU-friendly operations.

Related Logical functions

Rel

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

Tests

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

Bit

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

Logical

logical

Open-source implementation

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

  • View the source for lt 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 lt works
  • Does RunMat run lt on the GPU?
  • GPU memory and residency
  • Examples
  • Determine Whether One Scalar Is Less Than Another
  • Filter Matrix Elements Below A Threshold
  • Apply Less-Than With Implicit Expansion
  • Compare Character Data To Numeric Codes
  • Compare String Arrays Lexicographically
  • Run lt Directly On gpuArray Inputs
  • Using lt with coding agents
  • FAQ
  • Related Logical functions
  • Rel
  • Tests
  • Bit
  • Logical
  • Open-source implementation
  • About RunMat