pagetranspose — Apply the nonconjugate transpose to every matrix page of an array.
Y = pagetranspose(X) swaps the first two dimensions of X on every page without conjugating complex values. For N-D arrays, each output page Y(:,:,i,j,...) is the nonconjugate transpose of X(:,:,i,j,...).
Syntax
Y = pagetranspose(X)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
X | Any | Yes | — | Input scalar or array value. |
Returns
| Name | Type | Description |
|---|---|---|
Y | Any | Input value with the first two dimensions swapped on every page. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:pagetranspose:InvalidArgument | Call does not provide exactly one input argument. | pagetranspose: expected exactly one input argument |
RunMat:pagetranspose:InvalidInput | Input type is unsupported for page-wise transpose. | pagetranspose: unsupported input type |
RunMat:pagetranspose:Internal | Runtime cannot materialize the page-wise transpose output. | pagetranspose: internal runtime failure |
How pagetranspose works
- Equivalent to
permute(X,[2 1 3:ndims(X)])for dense arrays. - Works for scalars, vectors, matrices, and N-D arrays; only the first two axes are swapped.
- Complex values are not conjugated. Compose with
conjwhen Hermitian page transpose semantics are needed. - Logical, character, string, and cell arrays preserve their element type while their first two dimensions are swapped.
- Sparse matrices transpose through RunMat's sparse CSC transpose path.
- Scalar structs are treated as 1-by-1 values and round-trip unchanged; true struct-array permutation will follow RunMat's struct-array representation when that lands.
- gpuArray inputs remain device-resident when a provider is available; otherwise they fall back to host execution.
Does RunMat run pagetranspose on the GPU?
pagetranspose uses the same provider permute hook as permute(X,[2 1 3:ndims(X)]).
If the provider lacks a native hook, RunMat gathers, performs the page-wise transpose on the host, and uploads the result back to the provider.
GPU memory and residency
Yes for explicit gpuArray inputs when an acceleration provider is available.
Examples
Transpose each page of a 3-D array
A = reshape(1:12, [2 3 2]);
B = pagetranspose(A);
size(B)Expected output:
ans = [3 2 2]Preserve complex values without conjugation
Z = reshape([1+2i 3-4i], [1 2 1]);
Y = pagetranspose(Z)Expected output:
Y =
1.0000 + 2.0000i
3.0000 - 4.0000iUse pagetranspose as the page-wise form of transpose
A = rand(5, 3, 10);
B = pagetranspose(A);
size(B)Expected output:
ans = [3 5 10]Transpose gpuArray pages while preserving residency
G = gpuArray(rand(4, 2, 8));
H = pagetranspose(G);
isgpuarray(H)Expected output:
ans = logical 1Using pagetranspose with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how pagetranspose changes the result.
Run a small pagetranspose example, explain the result, then change one input and compare the output.
FAQ
How does pagetranspose differ from transpose?⌄
For dense arrays they use the same first-two-dimension swap. pagetranspose names the page-wise intent explicitly for N-D arrays and mirrors MATLAB's page-wise API.
Does pagetranspose conjugate complex numbers?⌄
No. It is the page-wise nonconjugate transpose.
What happens to dimensions three and higher?⌄
They stay in the same order and size. Only dimensions one and two are swapped.
Is the result a view?⌄
No. RunMat materializes a new value, although GPU providers may optimize the data movement internally.
Related Linalg functions
Ops
cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · 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 pagetranspose is executed, line by line, in Rust.
- View the source for pagetranspose 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.