transpose
result = transpose(A)
Input: A · Output: result
What it is
Matrix/vector transpose: swaps rows and columns. A is a Vec (treated as a single row or column) or Mat/CMat; an r×c input returns a c×r output of the same element type.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = transpose(A) | A Mat, vector, Vec, or CMatnot documented yet | result Mat, CMat, or Vec | Returns a Mat, or a CMat for a complex input — including for a Vec argument, which comes back as an n×1 column Mat rather than a Vec. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
A = [1, 2, 3; 4, 5, 6]
x = 5
print("val={val(x)}")
print(transpose(A))
print("mirror={mirror([1, 2, 3])}")
val=5 [1, 4; 2, 5; 3, 6] mirror=[3, 2, 1]
from core-math
How it works
d(transpose(x))/dx: transpose is a linear permutation of elements, so its own vjp is just transposing the upstream adjoint back — reuses the free transpose_value helper every OTHER vjp rule already calls for local derivatives (here it's the WHOLE rule, not just a local factor).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.