How do you transpose tensors?
Andrew Mclaughlin
We transpose a matrix $A$ by replacing $A_{ij}$ with $A_{ji}$, for all $i$ and $j$.
However, in case $A$ has more than two dimensions (that is, it is a tensor), I don't know how to apply the transpose operation.
If A has dimensions $3\times 3 \times 8$, then what will replace $A_{ijk}$?
If $A$ has shape $3\times 3\times 8\times 8$, then what will replace $A_{ijkl}$?
2 Answers
$\begingroup$The operation of taking a transpose is closely related to the concept of symmetry. One paper that addresses this is . I have been researching $2^m$ dimensional matrices where the indices are zeros and ones. The transpose is found by changing all zeros to ones and ones to zeros.
$\endgroup$ $\begingroup$Here is an example for 3D array,
First decide if it's row major (e.g. C) or column major (e.g. Fortran).
For a C array A[n3][n2][n1], the fastest dimension is n1, and we can name this original sequence as 321.
Then we can say we want a 321 -> 132 transpose operation, which is to copy the array element A[i3][i2][i1] to B[i1][i3][i2].
Often we assume from fastest dimension to slowest dimension being 123, then we can call the above transpose operation as 231 (i.e., 123->231).
$\endgroup$