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
    • cross
    • ctranspose
    • dot
    • mldivide
    • mpower
    • mrdivide
    • mtimes
    • pagemtimes
    • pagetranspose
    • trace
    • transpose

dot — Compute dot products in MATLAB and RunMat.

dot(A, B) evaluates inner products between matching slices of A and B, optionally along a selected dimension. Complex inputs use conjugate-on-first-argument semantics consistent with MATLAB and RunMat.

Syntax

C = dot(A, B)
C = dot(A, B, dim)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Left operand.
BAnyYes—Right operand.
dimNumericScalarYes—Reduction dimension.

Returns

NameTypeDescription
CNumericArrayDot product result.

Errors

IdentifierWhenMessage
RunMat:dot:InvalidArgumentArgument count or dimension argument is invalid.dot: invalid argument
RunMat:dot:InvalidInputInputs are unsupported or incompatible.dot: A and B must be the same size.
RunMat:dot:InternalRuntime cannot materialize dot outputs.dot: internal runtime failure

How dot works

  • Vectors need the same number of elements and may use different row/column orientations. Matrices and N-D arrays must have identical sizes.
  • When no dimension is supplied, the function reduces along the first non-singleton dimension (dim = 1 when all dimensions are singleton).
  • dot(A, B, dim) collapses dimension dim (1-based) while leaving every other dimension untouched.
  • Complex inputs conjugate the first argument before multiplication; real inputs use a straight element-wise product.
  • Single inputs produce single results, including on the host/fallback path; otherwise the floating result is double.
  • Empty reductions yield zeros of the appropriate shape; length mismatches raise A and B must be the same size.
  • Public MATLAB data inputs are single or double. RunMat additionally accepts logical and all eight typed-integer classes only in RunMat extension mode.
  • When both extension operands are typed integers, each product is formed from authoritative integer storage before crossing to the floating reduction/output domain, avoiding pre-product loss above flintmax.
  • Typed-integer dim is a documented control input, is available in compatibility modes, and is decoded exactly in every supported integer class.

Does RunMat run dot on the GPU?

Native dispatch never sends integer or logical storage to a floating dot hook. It requires proven common ownership/device and accepts a fresh result only after owner, device, shape, real noninteger storage, and operand-requested precision validation; malformed native results trigger the host fallback. Global-provider fallback for an unknown device is not accepted as ownership. Outputs that alias either input or the fallback residency anchor are rejected and never freed as provider-owned results. Other rejected allocations are freed only through a proven actual owner. Fallback gathers through each handle owner and restores real output to the first resident owner only after applying the same owner, device, shape, storage, class-metadata, freshness, and requested-precision checks.

GPU memory and residency

Same-owner, same-device real floating inputs can use the owning provider's native dot hook. Other supported resident forms gather through the originating owner and restore real results there when its precision can represent the output. Complex outputs remain host-side until provider complex dot support is available.

Examples

Computing the dot product of row vectors

A = [1 2 3];
B = [4 5 6];
val = dot(A, B)

Expected output:

val = 32

Dotting column vectors to obtain a scalar

u = [1; 3; 5];
v = [2; 4; 6];
val = dot(u, v)

Expected output:

val = 44

Applying dot along a chosen dimension

X = [1 2 3; 4 5 6];
Y = [6 5 4; 3 2 1];
cols = dot(X, Y, 1)  % collapse rows
rows = dot(X, Y, 2)  % collapse columns

Expected output:

cols = [18 20 18];
rows = [28; 28]

Dotting complex vectors uses conjugation on the first input

a = [1+2i, 3-4i];
b = [2-3i, -1+5i];
val = dot(a, b)

Expected output:

val = -27 + 4i

Evaluating dot on gpuArray inputs

G1 = gpuArray([1 2 3 4]);
G2 = gpuArray([4 3 2 1]);
G = dot(G1, G2);
result = gather(G)

Expected output:

result = 20

Using dot with coding agents

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

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

FAQ

Does dot require vectors?⌄

No. Any pair of tensors with identical sizes works; specifying a dimension lets you dot slices of higher-dimensional arrays.

How does the optional dimension behave?⌄

dot(A, B, dim) collapses the dimth dimension (1-based). Dimensions greater than the array rank have length 1 and therefore leave the data unchanged.

What happens with complex numbers?⌄

The first input is conjugated before multiplication so the result matches MATLAB's hermitian inner product.

Are empty inputs supported?⌄

Yes. If the reduction dimension has length 0 the result is filled with zeros of the appropriate shape.

Will the result stay on the GPU?⌄

When a provider is active the runtime uploads real-valued results back to the device. Complex outputs stay on the host until GPU complex support is available.

What error is raised for size mismatches?⌄

When A and B differ in size dot raises: A and B must be the same size. matching MATLAB's wording.

Does dot accept logical or integer inputs?⌄

Only as explicit RunMat extensions. Current public MATLAB documentation lists single and double data inputs. RunMat mode accepts logical and all eight integer classes; compatibility modes reject those data forms. Typed-integer dim remains documented and available.

Can I request conjugation of the second argument instead?⌄

No. MATLAB's dot is fixed to conjugate the first argument. Use sum(A .* conj(B)) manually if you need the opposite orientation.

Related Linalg functions

Ops

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

Structure

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

Factor

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

Solve

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

Open-source implementation

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

  • View the source for dot 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 dot works
  • Does RunMat run dot on the GPU?
  • GPU memory and residency
  • Examples
  • Computing the dot product of row vectors
  • Dotting column vectors to obtain a scalar
  • Applying dot along a chosen dimension
  • Dotting complex vectors uses conjugation on the first input
  • Evaluating dot on gpuArray inputs
  • Using dot with coding agents
  • FAQ
  • Related Linalg functions
  • Ops
  • Structure
  • Factor
  • Solve
  • Open-source implementation
  • About RunMat