({{, (RefLink[TensorTranspose, paclet:ref/TensorTranspose])[tensor,perm] 
represents the tensor obtained by transposing the slots of tensor as given by the permutation perm.}})

OpenersNotesSection(Spacer1)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 (RefLink[Cycles, paclet:ref/Cycles]). Cyclic notation is automatically transformed into list notation.

(RefLink[TensorTranspose, paclet:ref/TensorTranspose])[tensor] is equivalent to (RefLink[TensorTranspose, paclet:ref/TensorTranspose])[tensor,{2,1}].

OpenersPrimaryExamplesSection(Spacer1)Examples  (14)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Transpose the first two levels of a symbolic array of rank 3:

$Assumptions=A∈Arrays[{3,4,5}];

TensorTranspose[A]//TensorDimensions

Perform tensor operations on transposed symbolic tensors:

TensorTranspose[T,{2,4,3,1}]

TensorTranspose[%,{2,1}]

TensorContract[%,{{1,4}}]

OpenersExampleSection1(Spacer1)Scope  (3)

On normal arrays:

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}]+sa

Normal[%]

On symbolic tensors:

$Assumptions=A∈Arrays[{4,4,4},Reals,Antisymmetric[{1,2,3}]];

TensorTranspose[A,Cycles[{{2,3}}]]

The presence of symmetry allows further simplification:

%//TensorReduce

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (1)

Transpose tensors using symmetry generators of the form {perm,φ}, with φ a root of unity:

TensorTranspose[T,{{2,1},-1}]

TensorTranspose[T,{{2,3,4,1},I}]

OpenersExampleSection4(Spacer1)Applications  (1)

Given a Riemannian metric (∑_(μ=1)^n)(∑_(ν=1)^n)(Subscript[g, μν]) (((dx))^μ) (((dx))^ν), the so-called Christoffel coefficients of the first kind form a rank-three array with components given by the formula (Subscript[Γ, λμν])=(1/2) (((∂(Subscript[g, λμ]))/(∂ν))+((∂(Subscript[g, λν]))/(∂μ))-((∂(Subscript[g, μν]))/(∂λ))):

x = {r,θ};
g=CoordinateChartData["Polar","Metric",x]

Since (RefLink[Grad, paclet:ref/Grad]) adds a new innermost dimension, the first term in parentheses is merely (RefLink[Grad, paclet:ref/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]

OpenersExampleSection5(Spacer1)Properties & Relations  (7)

(RefLink[TensorTranspose, paclet:ref/TensorTranspose]) on arrays is equivalent to (RefLink[Transpose, paclet:ref/Transpose]):

array=Array[a,{2,3,2}];
perm={2,3,1};

TensorTranspose[array,perm]===Transpose[array,perm]

However, (RefLink[Transpose, paclet:ref/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}]//TensorDimensions

Permute[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[v1⊗v2⊗v3,{2,3,1}]]

TensorDimensions[Permute[v1⊗v2⊗v3,{2,3,1}]]

Permute[TensorDimensions[v1⊗v2⊗v3],{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}]

(RefLink[TensorTranspose, paclet:ref/TensorTranspose]) is always placed outside (RefLink[TensorContract, paclet:ref/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}]]

(RefLink[TensorTranspose, paclet:ref/TensorTranspose]) is a proper right action with respect to (RefLink[PermutationProduct, paclet:ref/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,perm1\[PermutationProduct]perm2]

But not in the opposite order:

TensorTranspose[A,perm2\[PermutationProduct]perm1]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Transpose, paclet:ref/Transpose])  ▪  (RefLink[Cycles, paclet:ref/Cycles])  ▪  (RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray])  ▪  (RefLink[Symmetric, paclet:ref/Symmetric])  ▪  (RefLink[Antisymmetric, paclet:ref/Antisymmetric])  ▪  (RefLink[TensorReduce, paclet:ref/TensorReduce])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Symbolic Tensors, paclet:tutorial/SymbolicTensors])}, {▪(RefLinkPlain[Tensor Symmetries, paclet:tutorial/TensorSymmetries])}, {▪(RefLinkPlain[Symmetrized Arrays, paclet:tutorial/SymmetrizedArrays])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Symbolic Tensors, paclet:guide/SymbolicTensors])}})}})