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

vecnorm — Compute vector-wise array norms.

vecnorm(A) returns vector-wise 2-norms. Matrices reduce down columns by default, multidimensional arrays reduce along the first nonsingleton dimension, and vecnorm(A,p,dim) reduces along an explicit dimension.

Syntax

N = vecnorm(A)
N = vecnorm(A, p)
N = vecnorm(A, p, dim)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input numeric array.
pAnyNo2Positive norm order or Inf.
dimAnyNo—Dimension to operate along.

Returns

NameTypeDescription
NNumericArrayVector-wise norm values.

Errors

IdentifierWhenMessage
RunMat:vecnorm:InvalidArgumentThe norm order or dimension argument is malformed or unsupported.vecnorm: invalid argument
RunMat:vecnorm:InvalidInputInput values cannot be converted to a supported numeric array domain.vecnorm: invalid input
RunMat:vecnorm:InternalRuntime fails while reducing, allocating, gathering, or uploading values.vecnorm: internal runtime failure

How vecnorm works

  • The output has the same shape as A except the operated dimension has length 1.
  • p may be any positive real scalar or Inf.
  • The documented input array classes are single and double. Native integer A is a RunMat language extension that requires exact conversion to double and returns double output.
  • Native integer storage for p is a separate RunMat language extension and must be exactly representable as double. Native integer dim is part of the compatibility surface and is decoded exactly as a structural dimension.
  • Single and complex-single inputs return single output; double, complex-double, and native integer extension inputs return double output.
  • Complex inputs are reduced using element magnitudes and return real non-negative values.
  • NaN values propagate within the vector being reduced.
  • When dim is greater than ndims(A), or size(A,dim) is 1, the result is abs(A) with the original shape.

Does RunMat run vecnorm on the GPU?

When no provider kernel is available, GPU inputs are gathered through their owning provider, vector-wise norms are computed with the same CPU logic as host arrays, and the result is restored to that provider when its physical precision matches the output class.

The fallback includes NaNs and preserves compatibility-target shape semantics. If the provider cannot preserve the result class or restoration fails, RunMat returns the correctly typed host result rather than relabelling or changing the numeric answer.

GPU memory and residency

G = gpuArray([3 5; 4 12]);
N = vecnorm(G)

Expected output:

N = [5 13]

Examples

Computing column-wise Euclidean norms

A = [2 0 1; -1 1 0; -3 3 0];
N = vecnorm(A)

Expected output:

N = [3.7417 3.1623 1]

Computing row-wise 1-norms

A = [1 3; 2 4];
N = vecnorm(A, 1, 2)

Expected output:

N = [4; 6]

Using a fractional positive norm order

x = [1; 4; 9];
N = vecnorm(x, 0.5)

Expected output:

N = 36

Reducing complex values by magnitude

z = [3+4i; 5+12i];
N = vecnorm(z)

Expected output:

N = 13.9284

Operating along a trailing dimension

A = reshape(1:8, [2 2 2]);
N = vecnorm(A, 2, 3)

Expected output:

N is size 2x2x1

Computing Vector Norms On GPU Data

G = gpuArray([3 5; 4 12]);
N = vecnorm(G)

Expected output:

N = [5 13]

Using vecnorm with coding agents

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

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

FAQ

How is vecnorm different from norm?⌄

norm(A) returns one scalar for a vector or matrix. vecnorm(A) reduces each vector along one dimension and returns an array of norms.

What dimension does vecnorm(A) use by default?⌄

It uses the first dimension whose size is not 1. For ordinary matrices this means column-wise norms.

Does vecnorm support complex arrays?⌄

Yes. Complex elements are converted to magnitudes before applying the selected vector norm.

Can p be less than 1?⌄

Yes. The compatibility target documents p as a positive scalar or Inf, and RunMat accepts positive fractional values.

What happens for dim beyond the rank of the input?⌄

RunMat follows the compatibility target by returning abs(A) with the original shape.

Will GPU inputs stay on the GPU?⌄

When a provider is active, RunMat gathers the input to compute the norm and uploads the result back to the provider. A future provider hook can replace this with a device-side kernel without changing user code.

Related Linalg functions

Solve

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

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

Related guides

  • MATLAB Language Extensions

Open-source implementation

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

  • View the source for vecnorm 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 vecnorm works
  • Does RunMat run vecnorm on the GPU?
  • GPU memory and residency
  • Examples
  • Computing column-wise Euclidean norms
  • Computing row-wise 1-norms
  • Using a fractional positive norm order
  • Reducing complex values by magnitude
  • Operating along a trailing dimension
  • Computing Vector Norms On GPU Data
  • Using vecnorm with coding agents
  • FAQ
  • Related Linalg functions
  • Solve
  • Structure
  • Factor
  • Ops
  • Related guides
  • Open-source implementation
  • About RunMat