3
$\begingroup$

According to the documentation, Transpose with a second argument {1,1} on a square matrix returns the diagonal of the matrix.

m = ArrayReshape[Range[25], {5, 5}];
Transpose[m, {1, 1}] == Diagonal[m]
(* True *)

Is it an arbitrary convention for the Transpose function, or does it correspond to some mathematical reality? It does not seem like an obvious consequence of the definition of transposition to me.

$\endgroup$
1
  • 4
    $\begingroup$ The documentation OP is referring to mentions this: Transpose allows the $n_i$ to be repeated, computing diagonals of the subarrays determined by the repeated levels. The result is therefore an array of smaller depth. $\endgroup$
    – flinty
    Commented Feb 7, 2022 at 11:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.