TensorTranspose[tensor,perm]
represents the tensor obtained by transposing the slots of tensor as given by the permutation perm.
TensorTranspose
TensorTranspose[tensor,perm]
represents the tensor obtained by transposing the slots of tensor as given by the permutation perm.
Details
- The tensor can be any form of explicit array (normal, sparse, or structured) or any symbolic expression representing a tensor, including tensor products, tensor contractions, etc.
- The permutation perm can be given as a permutation list or in cyclic notation with head Cycles. Cyclic notation is automatically transformed into list notation.
- TensorTranspose[tensor] is equivalent to TensorTranspose[tensor,{2,1}].
Examples
open all close allBasic Examples (2)
Transpose the first two levels of a symbolic array of rank 3:
$Assumptions = A∈Arrays[{3, 4, 5}];TensorTranspose[A]//TensorDimensionsPerform tensor operations on transposed symbolic tensors:
TensorTranspose[T, {2, 4, 3, 1}]TensorTranspose[%, {2, 1}]TensorContract[%, {{1, 4}}]Scope (3)
TensorTranspose[{{1, 2}, {3, 4}, {5, 6}}, Cycles[{{1, 2}}]]On symmetrized arrays. This is an antisymmetric array:
sa = SymmetrizedArray[{{1, 2, 3} -> a}, {4, 4, 4}, Antisymmetric[{1, 2, 3}]]TensorTranspose[sa, {1, 3, 2}] + saNormal[%]$Assumptions = A∈Arrays[{4, 4, 4}, Reals, Antisymmetric[{1, 2, 3}]];TensorTranspose[A, Cycles[{{2, 3}}]]The presence of symmetry allows further simplification:
%//TensorReduceGeneralizations & Extensions (1)
Applications (1)
Given a Riemannian metric
, the so-called Christoffel coefficients of the first kind form a rank-three array with components given by the formula
:
x = {r, θ};
g = CoordinateChartData["Polar", "Metric", x]Since Grad adds a new innermost dimension, the first term in parentheses is merely Grad[g,x]:
gradg123 = Grad[g, x]The second term keeps the first level in place but interchanges the second and third levels:
gradg132 = TensorTranspose[gradg123, {1, 3, 2}]The final term cyclically permutes the levels in the first term:
gradg231 = TensorTranspose[gradg123, {2, 3, 1}]Combining all the pieces yields the following:
(1/2)(gradg123 + gradg132 - gradg231)This procedure is automated using the following function:
firstChristoffel[g_, x_] := With[{dG = Grad[g, x]}, 1 / 2 (dG + TensorTranspose[dG, {1, 3, 2}] - TensorTranspose[dG, {2, 3, 1}])]Apply the function to the spherical metric:
x = {r, θ, φ};
g = CoordinateChartData["Spherical", "Metric", x];
firstChristoffel[g, x]Properties & Relations (7)
TensorTranspose on arrays is equivalent to Transpose:
array = Array[a, {2, 3, 2}];
perm = {2, 3, 1};TensorTranspose[array, perm] === Transpose[array, perm]However, Transpose allows second arguments that are not permutations:
Transpose[array, {1, 2, 1}]TensorTranspose[array, {1, 2, 1}]The dimensions of the transposed array are equal to the permuted dimensions of the original:
$Assumptions = A∈Arrays[{2, 3, 4, 5}];TensorTranspose[A, {3, 2, 4, 1}]//TensorDimensionsPermute[TensorDimensions[A], {3, 2, 4, 1}]Transposing a tensor product of vectors is equivalent to permuting those vectors:
$Assumptions = {v1∈Vectors[3], v2∈Vectors[4], v3∈Vectors[5]};TensorDimensions[TensorTranspose[v1v2v3, {2, 3, 1}]]TensorDimensions[Permute[v1v2v3, {2, 3, 1}]]Permute[TensorDimensions[v1v2v3], {2, 3, 1}]With symbolic tensors, the permutation is canonicalized to list form by default:
TensorTranspose[array, Cycles[{{1, 2, 3}}]]TensorTranspose[array]If the rank is known, the permutation list will be extended if possible:
$Assumptions = array∈Arrays[{2, 3, 2, 3, 2}];TensorTranspose[array, {2, 3, 1}]TensorTranspose[array]TensorTranspose[array, {2, 1}] == TensorTranspose[array, {2, 1, 3}]TensorTranspose is always placed outside TensorContract:
$Assumptions = A∈Arrays[{1, 2, 3, 3, 4}];TensorTranspose[A, {4, 3, 5, 1, 2}]TensorContract[%, {{1, 5}}]That is a transposition of a rank 3 symbolic array:
TensorRank[%]Combine transpositions of a symbolic tensor:
TensorTranspose[TensorTranspose[T, {2, 1, 4, 3}], {3, 2, 1}]Check it with explicit arrays:
With[{T = Array[t, {2, 2, 2, 2}]}, Transpose[Transpose[T, {2, 1, 4, 3}], {3, 2, 1}] === Transpose[T, {2, 3, 4, 1}]]TensorTranspose is a proper right action with respect to PermutationProduct:
perm1 = Cycles[{{2, 3, 4}, {5, 1}}];
perm2 = Cycles[{{1, 4}, {2, 5}}];TensorTranspose[TensorTranspose[A, perm1], perm2]The same result can be obtained by multiplying permutations in the same order:
TensorTranspose[A, perm1perm2]But not in the opposite order:
TensorTranspose[A, perm2perm1]Tech Notes
Related Guides
History
Text
Wolfram Research (2012), TensorTranspose, Wolfram Language function, https://reference.wolfram.com/language/ref/TensorTranspose.html.
CMS
Wolfram Language. 2012. "TensorTranspose." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TensorTranspose.html.
APA
Wolfram Language. (2012). TensorTranspose. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TensorTranspose.html
BibTeX
@misc{reference.wolfram_2026_tensortranspose, author="Wolfram Research", title="{TensorTranspose}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/TensorTranspose.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_tensortranspose, organization={Wolfram Research}, title={TensorTranspose}, year={2012}, url={https://reference.wolfram.com/language/ref/TensorTranspose.html}, note=[Accessed: 13-June-2026]}