RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

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.

/
See all docs
Builtin Reference
    • cond
    • det
    • inv
    • linsolve
    • norm
    • null
    • pinv
    • rank
    • rcond
    • rref
    • vecnorm

norm — Compute vector and matrix norms in MATLAB and RunMat.

norm(X) returns vector or matrix magnitudes. MATLAB-compatible data is single or double; all eight native integer classes and logical data are independently gated RunMat extensions.

Syntax

n = norm(A)
n = norm(A, p)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input vector or matrix.
pAnyNo—Norm order selector.

Returns

NameTypeDescription
nNumericScalarNorm value of A.

Errors

IdentifierWhenMessage
RunMat:norm:InvalidArgumentNorm-order argument is malformed or unsupported for the requested domain.norm: invalid argument
RunMat:norm:InvalidInputInput shape/type cannot be processed for norm evaluation.norm: invalid input
RunMat:norm:InternalRuntime fails while computing norm or executing fallback/upload paths.norm: internal runtime failure

How norm works

  • Single input returns a single scalar tensor; double input returns double. RunMat integer and logical extensions return double.
  • Typed-integer data remains authoritative until one checked binary64 norm boundary; values outside the exact binary64 integer range reject rather than round. If an owner cannot represent the required double output, automatic residency may finish on host while explicit gpuArray intent errors.
  • Positive real scalar orders and the documented norm keywords are accepted subject to vector-versus-matrix restrictions. Logical order selectors, zero norm, and nuclear norm are separately gated RunMat extensions.

Does RunMat run norm on the GPU?

Floating inputs use the exact owner's norm hook when it returns a fresh, correctly shaped and typed result. Unsupported hooks fall back to a non-consuming gather and class-preserving restoration. Integer and logical resident inputs are admitted only in RunMat mode and always take the checked host boundary instead of being mislabeled for a floating provider hook.

GPU memory and residency

G = gpuArray([3 4 12]);
mag = norm(G);      % falls back to CPU today; future providers can stay on device

Expected output:

mag = 13

Examples

Computing the Euclidean norm of a vector

x = [3 4];
mag = norm(x)

Expected output:

mag = 5

Calculating the Frobenius norm of a matrix

A = [1 -2 3; -4 5 -6];
f = norm(A, 'fro')

Expected output:

f = 9.5394

Using the infinity norm for robust bounds

x = [2 -7 4];
bound = norm(x, Inf)

Expected output:

bound = 7

Summing singular values with the nuclear norm

A = [2 0 0; 0 1 0];
tau = norm(A, 'nuc')

Expected output:

tau = 3

Computing the norm of complex-valued data

z = [1+2i 3-4i];
mag = norm(z)

Expected output:

mag = 5.4772

Preserving GPU residency transparently

G = gpuArray([3 4 12]);
mag = norm(G);      % falls back to CPU today; future providers can stay on device

Expected output:

mag = 13

Using norm with coding agents

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

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

FAQ

What is the difference between norm(x) and norm(x, 2)?⌄

No difference. Both compute the Euclidean norm for vectors (or the spectral norm for matrices).

Does norm support fractional powers?⌄

Positive real scalar orders, including supported fractional vector orders, use the compatibility surface. Zero norm is available only when RunMat extensions are enabled; Inf and -Inf retain their documented meanings.

Can I use norm on complex matrices?⌄

Absolutely. RunMat mirrors MATLAB by computing singular values in complex arithmetic and always returning a non-negative real scalar.

When should I use 'fro' versus 'nuc'?⌄

'fro' is part of the compatibility surface and returns the square root of the sum of squares. 'nuc' sums singular values but is a separately gated RunMat extension.

Why does norm of an empty matrix return 0?⌄

That matches MATLAB’s convention: the sum over an empty set is zero, so every supported norm returns 0 for empty inputs.

Can the norm overflow or underflow?⌄

Yes. The result obeys IEEE-754 double precision rules, just like MATLAB. Extremely large or tiny values may overflow to Inf or underflow toward zero.

Will the result stay on the GPU?⌄

RunMat uses a validated provider norm hook for supported floating inputs. Otherwise it gathers without consuming the source handle and restores the same-precision scalar to the exact owner when that owner can represent it.

Related Linalg functions

Solve

cond · det · inv · linsolve · null · pinv · rank · rcond · rref · 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 norm is executed, line by line, in Rust.

  • View the source for norm 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 norm works
  • Does RunMat run norm on the GPU?
  • GPU memory and residency
  • Examples
  • Computing the Euclidean norm of a vector
  • Calculating the Frobenius norm of a matrix
  • Using the infinity norm for robust bounds
  • Summing singular values with the nuclear norm
  • Computing the norm of complex-valued data
  • Preserving GPU residency transparently
  • Using norm with coding agents
  • FAQ
  • Related Linalg functions
  • Solve
  • Structure
  • Factor
  • Ops
  • Open-source implementation
  • About RunMat