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

mtimes — Multiply scalars, vectors, or matrices with matrix-product semantics.

mtimes(A, B) implements the callable form of A * B, including scalar, real, complex, integer-scalar, empty, and provider-resident cases.

Syntax

C = mtimes(A, B)

Inputs

A
Type
Any
Required
Yes
Description
Left numeric, logical, character, complex, or provider-resident operand.
B
Type
Any
Required
Yes
Description
Right numeric, logical, character, complex, or provider-resident operand.
NameTypeRequiredDefaultDescription
AAnyYes—Left numeric, logical, character, complex, or provider-resident operand.
BAnyYes—Right numeric, logical, character, complex, or provider-resident operand.

Returns

C
Type
NumericArray
Description
Matrix-arithmetic result.
NameTypeDescription
CNumericArrayMatrix-arithmetic result.

Errors

RunMat:mtimes:InvalidInput
When
Operands are unsupported or matrix dimensions are incompatible.
Message
mtimes: unsupported operand types
RunMat:mtimes:Internal
When
Runtime cannot complete a provider operation or materialize its output.
Message
mtimes: internal runtime failure
IdentifierWhenMessage
RunMat:mtimes:InvalidInputOperands are unsupported or matrix dimensions are incompatible.mtimes: unsupported operand types
RunMat:mtimes:InternalRuntime cannot complete a provider operation or materialize its output.mtimes: internal runtime failure

Matrix product

mtimes(A, B) and A * B multiply scalars, vectors, and matrices. For nonscalar matrices, size(A, 2) must equal size(B, 1). Row-by-column produces a scalar dot product, while column-by-row produces an outer product.

Scalars multiply every element without changing the other operand's shape. Logical and character operands enter floating-point arithmetic. An integer operand is supported only when the other operand is scalar; the result preserves the integer class and saturates.

Complex and empty arrays

Real and complex operands use full complex multiplication when either input is complex. Trailing singleton dimensions are accepted by the runtime's matrix view.

An m-by-0 matrix multiplied by a 0-by-n matrix produces an m-by-n zero matrix. Incompatible inner dimensions return a matrix-dimension error.

Sparse CPU operands

CPU sparse matrix products accept real or complex single and double values, and logical operands enter numeric arithmetic. Two sparse matrix operands produce a numeric sparse result; a sparse matrix paired with a full matrix produces a full result. Scalar products follow the scalar multiplication rules.

Nonscalar sparse matrix products require an unbounded host-memory policy. Calls with finite host-memory quotas are rejected because these sparse output and workspace bounds are not available.

Acceleration

A provider-resident product uses the exact owner of the resident operands. Compatible host operands may be uploaded to that owner. A typed unsupported-operation response permits host fallback; provider failures and invalid output metadata are reported.

Supported provider results retain device residency. Exact integer scalar fallback gathers authoritative typed storage and restores the result to the resident input's provider.

Examples

Multiply two matrices

A = [1 2 3; 4 5 6];
B = [7 8; 9 10; 11 12];
C = A * B

Expected output:

C = [58 64; 139 154]

Multiply a row by a column

u = [1 2 3];
v = [4; 5; 6];
d = mtimes(u, v)

Expected output:

d = 32

Scale a matrix

S = 0.5 * eye(3)

Expected output:

S = diag([0.5 0.5 0.5])

Multiply complex matrices

A = [1+2i 3-4i; 5+6i 7+8i];
B = [1-1i; 2+2i];
C = A * B

Expected output:

C = [17-1i; 9+31i]

Multiply provider-resident matrices

G1 = gpuArray(single([1 2; 3 4]));
G2 = gpuArray(single([5; 6]));
G = G1 * G2;
R = gather(G)

Expected output:

R = single([17; 39])

Reject incompatible inner dimensions

A = rand(2, 3);
B = rand(4, 2);
C = A * B

Expected output:

Inner matrix dimensions must agree.

Using mtimes with coding agents

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

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

FAQ

How is mtimes different from times?⌄

mtimes performs matrix products. times, written .*, multiplies corresponding elements with implicit expansion.

Does mtimes support scalars?⌄

Yes. A scalar scales the other operand. Integer inputs require this scalar form and preserve their fixed-width class.

Are complex values supported?⌄

Yes. A real/complex pair is promoted to complex arithmetic.

Will a result stay on its provider?⌄

A valid provider result remains resident. Only a typed unsupported operation may take the documented host fallback path.

Is matmul a callable alias?⌄

No. Use mtimes(A, B) or the A * B operator.

Related Linalg functions

Ops

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

Structure

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

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

Source you can read

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

  • View the source for mtimes 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
  • Matrix product
  • Complex and empty arrays
  • Sparse CPU operands
  • Acceleration
  • Examples
  • Multiply two matrices
  • Multiply a row by a column
  • Scale a matrix
  • Multiply complex matrices
  • Multiply provider-resident matrices
  • Reject incompatible inner dimensions
  • Using mtimes with coding agents
  • FAQ
  • Related Linalg functions
  • Ops
  • Structure
  • Factor
  • Solve
  • Source you can read
  • About RunMat