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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
X | NumericArray | Yes | — | Left dense single, double, or complex array. |
Y | NumericArray | Yes | — | Right dense single, double, or complex array. |
transpX | StringScalar | Yes | — | `none`, `transpose`, or `ctranspose` for X. |
transpY | StringScalar | Yes | — | `none`, `transpose`, or `ctranspose` for Y. |
Returns
| Name | Type | Description |
|---|---|---|
Z | NumericArray | Page-wise matrix product. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:pagemtimes:InvalidArity | The call does not use the two-argument or four-argument form. | pagemtimes: expected X,Y or X,transpX,Y,transpY |
RunMat:pagemtimes:InvalidInput | Inputs are not dense single, double, or complex arrays. | pagemtimes: inputs must be dense single, double, or complex arrays |
RunMat:pagemtimes:InvalidTranspose | Transpose flags are not one of none, transpose, or ctranspose. | pagemtimes: transpose options must be 'none', 'transpose', or 'ctranspose' |
RunMat:pagemtimes:PageDimensionMismatch | Trailing page dimensions cannot be implicitly expanded. | pagemtimes: page dimensions are not compatible |
RunMat:pagemtimes:MatrixDimensionMismatch | Matrix dimensions are not valid for page-wise multiplication. | pagemtimes: inner matrix dimensions must agree |
RunMat:pagemtimes:InternalError | Runtime cannot materialize the page-wise result. | pagemtimes: internal runtime failure |
How pagemtimes works
- Supports
Z = pagemtimes(X,Y)andZ = pagemtimes(X,transpX,Y,transpY). transpXandtranspYmust both be present in the four-argument form and each must benone,transpose, orctranspose.- 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
1or 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
ctransposeconjugates each page before multiplication;transposeonly 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 5Implicit 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 3GPU 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.
Related Linalg functions
Ops
cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagetranspose · trace · transpose
Structure
bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how pagemtimes is executed, line by line, in Rust.
- View the source for pagemtimes 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.