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
    • blkdiag
    • cat
    • circshift
    • diag
    • flip
    • fliplr
    • flipud
    • horzcat
    • ipermute
    • kron
    • permute
    • repelem
    • repmat
    • reshape
    • rot90
    • shiftdim
    • squeeze
    • toeplitz
    • tril
    • triu
    • vertcat

kron — Compute Kronecker products in MATLAB and RunMat.

kron(A, B) forms the Kronecker (tensor) product of A and B. Output sizing and column-major block ordering follow MATLAB semantics.

Syntax

C = kron(A, B)

Inputs

A
Type
Any
Required
Yes
Description
Left numeric, logical, character, or sparse input.
B
Type
Any
Required
Yes
Description
Right numeric, logical, character, or sparse input.
NameTypeRequiredDefaultDescription
AAnyYes—Left numeric, logical, character, or sparse input.
BAnyYes—Right numeric, logical, character, or sparse input.

Returns

C
Type
Any
Description
Kronecker product of A and B.
NameTypeDescription
CAnyKronecker product of A and B.

Errors

RunMat:kron:TooManyInputs
When
Extra arguments were supplied after A and B.
Message
kron: too many input arguments
RunMat:kron:UnsupportedInput
When
Input values are not supported numeric, logical, character, or sparse arrays.
Message
kron: unsupported input type
RunMat:kron:Internal
When
Internal conversion, allocation, or provider path fails.
Message
kron: internal operation failed
IdentifierWhenMessage
RunMat:kron:TooManyInputsExtra arguments were supplied after A and B.kron: too many input arguments
RunMat:kron:UnsupportedInputInput values are not supported numeric, logical, character, or sparse arrays.kron: unsupported input type
RunMat:kron:InternalInternal conversion, allocation, or provider path fails.kron: internal operation failed

Inputs and output

Scalars, vectors, and matrices are supported. An operand with more than two dimensions is a separately gated RunMat extension.

Each output extent is the checked product of the corresponding input extents; zero extents remain empty. A scalar operand scales the other operand.

Complex operands produce complex output. Logical and character operands are promoted to double precision before multiplication.

All eight real integer classes are supported: matching integer classes multiply with saturation, or a scalar double may scale an integer operand. Complex integer arithmetic and other mixed integer-array classes are rejected.

Sparse input uses the CSC Kronecker implementation and preserves sparse output without a dense conversion. Explicit device intent cannot publish a sparse host result.

GPU and fusion

Compatible resident floating operands use the owning provider's kron hook when available. Other supported forms gather authoritative data, compute on the host, and restore a class-preserving result to the source provider when possible.

Explicit gpuArray inputs either return a resident result or raise an error. The operation is a fusion boundary; no elementwise fusion kernel is claimed.

Automatic offload may keep compatible values resident without an explicit gpuArray call. Provider outputs are checked for shape, owner, device, storage, precision, and non-aliasing before publication.

Examples

Computing the Kronecker product of two matrices

A = [1 2; 3 4];
B = [0 5; 6 7];
C = kron(A, B)

Expected output:

C =
     0     5     0    10
     6     7    12    14
     0    15     0    20
    18    21    24    28

Kronecker product with row and column vectors

row = [1 2 3];
col = (1:3)';
K = kron(row, col);
size(K)

Expected output:

ans =
     3     9

Scaling a matrix with a scalar

A = [1 2; 3 4];
S = kron(2, A)

Expected output:

S =
     2     4
     6     8

Building block-diagonal systems

I = eye(3);
M = [1 0; 0 -1];
blockDiag = kron(I, M)

Kronecker product of complex matrices

A = [1+2i 0; 0 3-1i];
B = [0 1; 2 3i];
C = kron(A, B)

Using logical masks

mask = logical([1 0; 0 1]);
tile = kron(mask, ones(2))

Running kron on GPU-resident tensors

G = gpuArray(rand(2));
H = gpuArray([1 -1; -1 1]);
K = kron(G, H);
isgpuarray(K)

Expected output:

ans = logical 1

Using kron with coding agents

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

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

FAQ

When should I use kron instead of matrix multiplication?⌄

Use kron for block matrices built from every pair of operand elements; matrix multiplication contracts dimensions.

Does kron preserve sparsity?⌄

Yes. The current CSC path multiplies stored entries and returns sparse output; it does not densify sparse operands.

Can I mix real and complex inputs?⌄

Yes. Either complex operand produces complex output with the corresponding real and imaginary arithmetic.

What happens with logical inputs?⌄

Logical values become double-precision zeroes and ones before multiplication.

Are character arrays supported?⌄

Yes. Characters are converted to their Unicode code points in double precision.

How big can the result be?⌄

Output dimensions and element count are checked for overflow before allocation.

Does the GPU path always stay on-device?⌄

Compatible floating inputs use an owning-provider hook; otherwise a supported fallback gathers and restores when class and ownership permit. Explicit gpuArray inputs never silently become host results.

Related Array functions

Shape

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

Accumulation

accumarray

Sorting Sets

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

Creation

colon · createArray · empty · eye · false · full · inf · int16.empty · int32.empty · int64.empty · int8.empty · linspace · logspace · magic · meshgrid · nan · ndgrid · nonzeros · ones · peaks · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · uint16.empty · uint32.empty · uint64.empty · uint8.empty · zeros

Combinatorics

combinations · nchoosek · perms

Binning

discretize

Indexing

find · ind2sub · sub2ind

Grouping

findgroups · groupcounts · grp2idx · splitapply

Introspection

height · iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size · width

Source you can read

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

  • View the source for kron 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
  • Inputs and output
  • GPU and fusion
  • Examples
  • Computing the Kronecker product of two matrices
  • Kronecker product with row and column vectors
  • Scaling a matrix with a scalar
  • Building block-diagonal systems
  • Kronecker product of complex matrices
  • Using logical masks
  • Running kron on GPU-resident tensors
  • Using kron with coding agents
  • FAQ
  • Related Array functions
  • Shape
  • Accumulation
  • Sorting Sets
  • Creation
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Introspection
  • Source you can read
  • About RunMat