pagemtimes — Multiply corresponding matrix pages in dense arrays.

pagemtimes(X,Y) multiplies each corresponding two-dimensional matrix page of X and Y. Dimensions three and higher are page dimensions and use MATLAB-compatible singleton expansion.

Syntax

Z = pagemtimes(X, Y)
Z = pagemtimes(X, transpX, Y, transpY)

Inputs

NameTypeRequiredDefaultDescription
XNumericArrayYesLeft dense single, double, or complex array.
YNumericArrayYesRight dense single, double, or complex array.
transpXStringScalarYes`none`, `transpose`, or `ctranspose` for X.
transpYStringScalarYes`none`, `transpose`, or `ctranspose` for Y.

Returns

NameTypeDescription
ZNumericArrayPage-wise matrix product.

Errors

IdentifierWhenMessage
RunMat:pagemtimes:InvalidArityThe call does not use the two-argument or four-argument form.pagemtimes: expected X,Y or X,transpX,Y,transpY
RunMat:pagemtimes:InvalidInputInputs are not dense single, double, or complex arrays.pagemtimes: inputs must be dense single, double, or complex arrays
RunMat:pagemtimes:InvalidTransposeTranspose flags are not one of none, transpose, or ctranspose.pagemtimes: transpose options must be 'none', 'transpose', or 'ctranspose'

How pagemtimes works

  • Supports Z = pagemtimes(X,Y) and Z = pagemtimes(X,transpX,Y,transpY).
  • transpX and transpY must both be present in the four-argument form and each must be none, transpose, or ctranspose.
  • The first two dimensions of each input form the matrix multiplied on each page. Page dimensions are dimensions three and higher and are expanded by position when one side has extent 1 or omits the trailing dimension.
  • If either operand is scalar, the result uses the first two dimensions of the nonscalar operand and performs page-wise scalar multiplication.
  • Dense double, single, and complex double arrays are supported. Integer, logical, sparse, cell, struct, object, and text inputs are rejected.
  • Complex ctranspose conjugates each page before multiplication; transpose only swaps the first two dimensions.

Does RunMat run pagemtimes on the GPU?

pagemtimes exposes a custom GPU spec and keeps outputs resident when any input is a gpuArray and an acceleration provider is available.

Plain page-wise products may be accelerated by provider pagefun hooks in future backends; transpose and scalar forms currently use the host-complete fallback path.

GPU memory and residency

Yes for explicit gpuArray inputs. RunMat gathers when needed for host-complete semantics, then re-uploads real and complex numeric results to the active acceleration provider.

Examples

Multiply matching pages

X = reshape(1:8, [2 2 2]);
Y = reshape(10:17, [2 2 2]);
Z = pagemtimes(X,Y)

Broadcast a matrix across all pages

X = eye(2);
Y = reshape(1:8, [2 2 2]);
Z = pagemtimes(X,Y)

Use transpose options

X = rand(2,3,5);
Y = rand(2,4,5);
Z = pagemtimes(X,'transpose',Y,'none');
size(Z)

Expected output:

ans =
     3     4     5

Implicit expansion of page dimensions

X = rand(10,8,1,3);
Y = rand(8,10,4,1);
Z = pagemtimes(X,Y);
size(Z)

Expected output:

ans =
    10    10     4     3

GPU inputs remain device-resident

G = gpuArray(rand(3,3,8));
H = pagemtimes(G,2);
firstPage = gather(H(:,:,1));

Using pagemtimes with coding agents

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

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

FAQ

How does pagemtimes differ from mtimes?

mtimes multiplies two matrices. pagemtimes treats every slice in dimensions three and higher as an independent matrix and multiplies corresponding pages with singleton expansion across page dimensions.

Can I specify only one transpose option?

No. MATLAB's four-argument form requires both transpX and transpY; use none for the operand that should not be transposed.

What happens when page dimensions do not match?

RunMat raises RunMat:pagemtimes:PageDimensionMismatch unless the differing page extent is 1 or omitted on one side.

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 pagemtimes is executed, line by line, in Rust.

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.