transposes the first two levels in list.


transposes list so that the k^(th) level in list is the nk^(th) level in the result.


transposes levels m and n in list, leaving all other levels unchanged.

Details and Options

  • Transpose[m] gives the usual transpose of a matrix m.
  • Transpose[m] can be input as m.
  • can be entered as tr or \[Transpose].
  • For a matrix m, Transpose[m] is equivalent to Transpose[m,{2,1}].
  • For an array a of depth r3, Transpose[a] is equivalent to Transpose[a,{2,1,3,,r}], only transposing the first two levels.
  • The ni in Transpose[a,{n1,n2,}] or Transpose[a,n1n2] must be positive integers no larger than ArrayDepth[a].
  • If {n1,n2,} is a permutation list, then the element at position {i1,i2,} of Transpose[a,{n1,n2,}] is the element at position {in1,in2,} of the array a.
  • For a permutation perm, the dimensions of Transpose[a,perm] are Permute[Dimensions[a],perm].
  • A permutation list perm in Transpose[a,perm] can also be given in Cycles form, as returned by PermutationCycles[perm].
  • Transpose[a,mn] or Transpose[a,TwoWayRule[m,n]] is equivalent to Transpose[a,Cycles[{{m,n}}]].
  • Transpose allows the ni to be repeated, computing diagonals of the subarrays determined by the repeated levels. The result is therefore an array of smaller depth.
  • For a square matrix m, Transpose[m,{1,1}] returns the main diagonal of m, as given by Diagonal[m].
  • In general, if np=nq then the operation Transpose[a,{n1,n2,}] is possible for an array a of dimensions {d1,d2,} if dp=dq.
  • Transpose works on SparseArray and structured array objects.


open allclose all

Basic Examples  (2)

Transpose a 2×3 matrix:

Use followed by tr to enter the transposition operator:

Scope  (9)

Enter a matrix as a grid:

Transpose the matrix and format the result:

Transpose an array of depth 3 using different permutations:

Transpose levels 2 and 3 of a depth-4 array:

The second and third dimensions have been exchanged:

Perform transpositions using Cycles notation:

Perform transpositions using TwoWayRule notation:

s is a sparse matrix:

Transpose[s] is also sparse:

The indices have, in effect, just been reversed:

Transpose a SymmetrizedArray object:

The result equals the negative of the original array, due to its antisymmetry:

Get the leading diagonal by transposing two identical levels:

Format a symbolic transpose in TraditionalForm:

Applications  (2)

Transpose Table data to make ListPlot3D produce a similar result to Plot in a related case:

Multidimensionalize (in the tensor product sense) a one-dimensional list command:

Accumulate values of a tensor at all levels:

Import data from an image:

Flip the image by reversing at both levels:

Properties & Relations  (11)

Take an array with dimensions 2, 3, 4:

Transposing by a permutation σ transposes the element positions by σ-1:

Transpose[a,perm] returns an array of dimensions Permute[Dimensions[a],perm]:

Transpose[a] transposes the first two levels of an array:

Transpose[a,Cycles[{{m,n}}]] and Transpose[a,mn] are equivalent:

Both forms are equivalent to using PermutationList[Cycles[{{m,n}}]:

Transposition of {{}} returns {}:

The result cannot be {{}} again because the permutation of the dimensions {1,0} is {0,1} and no expression can have dimensions {0,1}:

Transposition of a vector is only compatible with the second argument {1}:

Composition of transpositions is equivalent to a product of their permutations, in the same order:

Transpositions do not commute, in general:

Transposition of a matrix can also be performed with Thread:

Transpose[m,{1,1}] is equivalent to Diagonal[m]:

Transpose[a,{1,,1,2,3,}] is equivalent to tracing the levels being transposed to level 1:

Transpose[a,σ] is equivalent to Flatten[a,List/@InversePermutation[σ]]:

Possible Issues  (1)

Transpose only works for rectangular arrays:

Generalize transposition by padding:

Eliminate the padding:

Neat Examples  (1)

Wolfram Research (1988), Transpose, Wolfram Language function, (updated 2017).


Wolfram Research (1988), Transpose, Wolfram Language function, (updated 2017).


@misc{reference.wolfram_2021_transpose, author="Wolfram Research", title="{Transpose}", year="2017", howpublished="\url{}", note=[Accessed: 28-October-2021 ]}


@online{reference.wolfram_2021_transpose, organization={Wolfram Research}, title={Transpose}, year={2017}, url={}, note=[Accessed: 28-October-2021 ]}


Wolfram Language. 1988. "Transpose." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017.


Wolfram Language. (1988). Transpose. Wolfram Language & System Documentation Center. Retrieved from