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
    • 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

perms — Return all permutations of a vector as rows.

P = perms(v) returns every permutation of the elements in vector v, one permutation per row. RunMat follows MATLAB's reverse lexicographic row order and preserves supported vector container classes.

Syntax

P = perms(v)

Inputs

NameTypeRequiredDefaultDescription
vAnyYes—Input vector to permute.

Returns

NameTypeDescription
PAnyMatrix whose rows contain every permutation of the input vector.

Errors

IdentifierWhenMessage
RunMat:perms:InvalidInputThe input is missing, not a vector, or has an unsupported type.perms: input must be a vector
RunMat:perms:TooLargeThe factorial-size output would exceed RunMat's supported materialisation limit.perms: output is too large
RunMat:perms:InternalOutput allocation, GPU gather, or container construction failed.perms: internal error

How perms works

  • perms(v) accepts row vectors, column vectors, scalars, and empty vectors.
  • The output has factorial(numel(v)) rows and numel(v) columns.
  • Rows are emitted in MATLAB-compatible reverse lexicographic permutation order relative to the original element positions.
  • Duplicate input values are permuted by position and are not deduplicated.
  • Dense numeric tensors preserve their native class and exact values, including all eight integer classes and wide 64-bit values; logical, character, string-array, and cell-array vectors return matching container types.
  • Scalar numeric, logical, and string inputs return the scalar value unchanged.
  • Complex numeric vectors are permuted positionally and preserve their complex values.
  • Inputs that are not vectors, unsupported object-like values, sparse tensors, and outputs beyond RunMat's materialization limit raise stable errors.

Examples

Permute a numeric vector

P = perms([1 2 3])

Expected output:

P =
     3     2     1
     3     1     2
     2     3     1
     2     1     3
     1     3     2
     1     2     3

Permute characters

P = perms('abc')

Expected output:

P =
    'cba'
    'cab'
    'bca'
    'bac'
    'acb'
    'abc'

Duplicate values are retained

P = perms([1 1 2])

Expected output:

% P has six rows; duplicate rows are preserved.

Work with an empty vector

P = perms([])

Expected output:

% P is a 1-by-0 empty double array.

Using perms with coding agents

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

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

FAQ

Why can perms error for long vectors?⌄

perms materializes factorial(numel(v)) * numel(v) elements. RunMat rejects outputs beyond its configured materialization limit instead of exhausting memory.

Does perms remove duplicate rows?⌄

No. Like MATLAB, values are permuted by position. Repeated input values can therefore produce repeated rows.

Can perms run on gpuArray inputs?⌄

RunMat gathers through the owning provider, constructs the result on the host, and restores the same-class result to that provider. Explicit gpuArray input fails if the provider cannot preserve residency.

Related Array functions

Creation

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

Grouping

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

Sorting Sets

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

Shape

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

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 perms is executed, line by line, in Rust.

  • View the source for perms 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 perms works
  • Examples
  • Permute a numeric vector
  • Permute characters
  • Duplicate values are retained
  • Work with an empty vector
  • Using perms with coding agents
  • FAQ
  • Related Array functions
  • Creation
  • Grouping
  • Sorting Sets
  • Shape
  • Indexing
  • Introspection
  • Open-source implementation
  • About RunMat