RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.2, Nov 26, 2026 ·

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.

/
See all docs
Builtin Reference
    • bandwidth
    • isdiag
    • ishermitian
    • issymmetric
    • istril
    • istriu
    • symrcm

symrcm — Compute symmetric reverse Cuthill-McKee permutations that reduce matrix bandwidth.

r = symrcm(A) returns a permutation vector for reordering symmetric or structurally symmetric matrices to reduce bandwidth. Use A(r, r) to obtain a tighter band structure, matching MATLAB-compatible ordering behavior.

Syntax

p = symrcm(A)

Inputs

A
Type
Any
Required
Yes
Description
Input matrix.
NameTypeRequiredDefaultDescription
AAnyYes—Input matrix.

Returns

p
Type
NumericArray
Description
Permutation row vector (1-based indices) from reverse Cuthill-McKee ordering.
NameTypeDescription
pNumericArrayPermutation row vector (1-based indices) from reverse Cuthill-McKee ordering.

Errors

RunMat:symrcm:InvalidInput
When
Input shape/type cannot be interpreted as a numeric or logical square matrix.
Message
symrcm: invalid input
RunMat:symrcm:Internal
When
Runtime fails while constructing intermediate tensors or adjacency structures.
Message
symrcm: internal runtime failure
IdentifierWhenMessage
RunMat:symrcm:InvalidInputInput shape/type cannot be interpreted as a numeric or logical square matrix.symrcm: invalid input
RunMat:symrcm:InternalRuntime fails while constructing intermediate tensors or adjacency structures.symrcm: internal runtime failure

Behavior and supported arrays

r = symrcm(A) returns a permutation vector for reordering square matrices to reduce bandwidth. Use A(r, r) to obtain a tighter band structure. More than one valid RCM ordering can exist, so exact permutation values need not match another implementation.

Treats the input as an undirected graph based on the structural pattern of A and A'. Any value that is not exactly zero (including NaN or Inf) creates an edge; diagonal entries are ignored.

Accepts full or sparse numeric, logical, and complex matrices. Host sparse CSC indices and native typed values build the graph without densification. Explicit numeric zeros are ignored; logical sparse pattern entries are true. Integer entries are tested for zero exactly, and complex entries are nonzero when either component is nonzero.

Requires a square matrix (scalars and the empty matrix are allowed). Inputs with more than two non-singleton dimensions raise an error, matching MATLAB matrix semantics.

Processes disconnected components independently. A degree/index-stable pseudoperipheral search chooses each component start, then Cuthill-McKee breadth-first search and reversal yield a deterministic symmetric ordering.

Returns a row vector of 1-based indices. Fully diagonal or zero matrices produce the identity permutation.

GPU residency and provider behavior

Resident matrix input is admitted through its owning acceleration provider. Explicit gpuArray is optional in RunMat; the current WGPU sym_rcm hook downloads the matrix and runs the host ordering algorithm rather than claiming a device-side RCM kernel.

RunMat first asks the active acceleration provider whether it implements the sym_rcm hook. A typed unsupported-hook result permits an owning-provider gather and host calculation. Other provider errors remain terminal and are not replayed as a host calculation.

Acceleration providers may implement the sym_rcm hook. The WGPU backend currently downloads the matrix, runs the host algorithm, and returns the permutation.

The provider specification accepts single and double precision, without broadcasting. This one-input graph operation is neither an elementwise fusion nor a reduction fusion; its runtime specification uses inline literals. No optional feature is required.

Examples

Reducing bandwidth of a near-band matrix

A = [4 1 0 0 2;
     1 4 1 0 0;
     0 1 4 1 0;
     0 0 1 4 1;
     2 0 0 1 4];
r = symrcm(A);
B = A(r, r);
bandwidth(A)
bandwidth(B)

Handling disconnected components with symrcm

A = [1 1 0 0 0;
     1 1 0 0 0;
     0 0 1 0 1;
     0 0 0 1 1;
     0 0 1 1 1];
r = symrcm(A);
B = A(r, r)

Using symrcm with logical adjacency matrices

adj = logical([0 1 0 0;
               1 0 1 0;
               0 1 0 1;
               0 0 1 0]);
r = symrcm(adj)

Applying symrcm to GPU matrices

G = gpuArray([0 1 0 0 2;
              1 0 1 0 0;
              0 1 0 1 0;
              0 0 1 0 1;
              2 0 0 1 0]);
r = symrcm(G);
H = gather(G(r, r))

Using symrcm with coding agents

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

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

FAQ

What class of matrices benefit from symrcm?⌄

Sparse or full square matrices whose graph bandwidth dominates solver cost, such as discretised PDE operators, circuit matrices, or graph Laplacians. Host sparse CSC input builds the symmetric graph directly without densifying.

Does symrcm modify the matrix?⌄

No. It returns a permutation vector. Apply it as A(r, r) or reorder vectors with x(r).

What happens if the matrix is not symmetric?⌄

RunMat creates an undirected edge whenever either A(i, j) or A(j, i) is nonzero. It combines their structural patterns without numerically adding the entries, so opposite values do not cancel an edge. Asymmetric inputs still produce a valid permutation.

Are diagonal entries considered?⌄

Diagonal entries are ignored when building the graph. Only off-diagonal nonzeros contribute edges.

How are NaNs or Infs handled?⌄

Any value that is not numerically equal to zero is treated as nonzero, including NaN or Inf.

Can I use symrcm on dense matrices?⌄

Yes. Full arrays use their nonzero pattern, just as sparse arrays do. A matrix with every off-diagonal entry nonzero has no bandwidth reduction available; its returned permutation need not be the identity.

How do I verify the permutation improves bandwidth?⌄

Compute bandwidth(A) and bandwidth(A(r, r)) and compare the results. Lower lower/upper bandwidth values indicate a tighter band and more efficient factorizations.

What output shape should I expect?⌄

The permutation is returned as a row vector (1 × n). The empty matrix returns the empty row vector [].

Related Linalg functions

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu

Factor

chol · decomposition · decomposition.ctranspose · decomposition.mldivide · decomposition.mrdivide · decomposition.mtimes · decomposition.rdivide · decomposition.subsref · decomposition.times · decomposition.uminus · decomposition.uplus · eig · eigs · gmres · ichol · ilu · lu · ordeig · ordqz · ordschur · pcg · qr · qz · rsf2csf · schur · svd

Solve

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

Ops

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

Source you can read

Every RunMat function's source is public. Read exactly how symrcm is executed, line by line, in Rust.

  • View the source for symrcm in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Behavior and supported arrays
  • GPU residency and provider behavior
  • Examples
  • Reducing bandwidth of a near-band matrix
  • Handling disconnected components with symrcm
  • Using symrcm with logical adjacency matrices
  • Applying symrcm to GPU matrices
  • Using symrcm with coding agents
  • FAQ
  • Related Linalg functions
  • Structure
  • Factor
  • Solve
  • Ops
  • Source you can read
  • About RunMat