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
    • cond
    • det
    • inv
    • linsolve
    • norm
    • null
    • pinv
    • rank
    • rcond
    • rref
    • vecnorm

rref — Compute reduced row echelon form and pivot columns.

rref(A) returns the reduced row echelon form of a real or complex numeric matrix. [R, pivots] = rref(A) also returns the one-based pivot column indices. An optional tolerance controls which entries are considered zero during pivot selection.

Syntax

R = rref(A)
R = rref(A, tol)
[R, pivots] = rref(A)
[R, pivots] = rref(A, tol)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input matrix.
tolNumericScalarNo—Pivot tolerance.

Returns

NameTypeDescription
RNumericArrayReduced row echelon form of A.
pivotsNumericArrayOne-based pivot column indices.

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

Errors

IdentifierWhenMessage
RunMat:rref:InvalidArgumentOptional tolerance argument is malformed or outside accepted bounds.rref: invalid argument
RunMat:rref:InvalidInputInput shape/type cannot be processed for row reduction.rref: invalid input
RunMat:rref:TooManyOutputsMore than two output arguments are requested.rref: too many output arguments
RunMat:rref:InternalRuntime fails while computing row reduction or executing gather/upload paths.rref: internal runtime failure

How rref works

  • Inputs must behave like 2-D matrices. Trailing singleton dimensions are accepted; other higher-rank inputs raise RunMat:rref:InvalidInput.
  • The default tolerance is max(size(A)) * eps(norm(A, inf)), matching MATLAB row-reduction conventions.
  • rref(A, tol) uses a caller-provided finite, non-negative scalar pivot tolerance.
  • The MATLAB-compatible matrix and tolerance classes are single and double. RunMat mode additionally accepts integer matrices and integer tolerances only through explicit exact-binary64 checks; strict MATLAB mode rejects those extensions.
  • Complex inputs use complex Gauss-Jordan elimination with pivot selection by complex magnitude.
  • The second output is a row vector of one-based pivot column indices.
  • Non-finite values are accepted. The default tolerance still follows max(size(A)) * eps(norm(A, inf)); Inf and NaN therefore follow the runtime's IEEE floating-point tolerance and pivot arithmetic.

Does RunMat run rref on the GPU?

rref is an eager solve-style operation. It terminates fusion plans, gathers GPU-resident inputs for numerical row reduction, and returns ordinary MATLAB-compatible values.

GPU memory and residency

When the input is a real gpuArray, RunMat gathers it, computes the row-reduced matrix on the host, and re-uploads the reduced matrix through that handle's owning provider. If owner-preserving re-upload fails, the builtin raises RunMat:rref:Internal rather than silently changing residency. Pivot-column metadata is returned as a host vector.

Examples

Finding dependent columns

A = [1 2 3; 2 4 6; 1 1 1];
[R, pivots] = rref(A)

Expected output:

R = [1 0 -1; 0 1 2; 0 0 0]
pivots = [1 2]

Using a custom tolerance

A = diag([1, 1e-12]);
R = rref(A, 1e-6)

Expected output:

R = [1 0; 0 0]

Row-reducing an augmented system

A = [2 -1 3; 4 -2 6; 1 0 1];
b = [5; 10; 2];
RAug = rref([A b])

Using rref with coding agents

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

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

FAQ

How does rref choose pivots?⌄

RunMat scans columns left to right, picks the largest available pivot by magnitude below the current pivot row, normalizes the pivot row, and eliminates the pivot column above and below the pivot.

Is the pivot vector one-based?⌄

Yes. The second output uses MATLAB's one-based column indices.

Does rref use the same tolerance as rank?⌄

No. rank uses an SVD tolerance. rref uses the MATLAB row-reduction tolerance based on the matrix infinity norm.

Related Linalg functions

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · vecnorm

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

Factor

chol · decomposition · eig · eigs · lu · qr · svd

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Open-source implementation

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

  • View the source for rref 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 rref works
  • Does RunMat run rref on the GPU?
  • GPU memory and residency
  • Examples
  • Finding dependent columns
  • Using a custom tolerance
  • Row-reducing an augmented system
  • Using rref with coding agents
  • FAQ
  • Related Linalg functions
  • Solve
  • Structure
  • Factor
  • Ops
  • Open-source implementation
  • About RunMat