# Transpose

Transpose[list]

transposes the first two levels in list.

Transpose[list,{n_{1},n_{2},…}]

transposes list so that the k level in list is the n_{k} level in the result.

Transpose[list,mn]

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

Transpose[list,k]

cycles the levels in list k positions to the right.

# 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 r≥3, Transpose[a] is equivalent to Transpose[a,{2,1,3,…,r}], only transposing the first two levels. »
- The n
_{i}in Transpose[a,{n_{1},n_{2},…}] or Transpose[a,n_{1}n_{2}] must be positive integers no larger than ArrayDepth[a]. - If {n
_{1},n_{2},…} is a permutation list, then the element at position {i_{1},i_{2},…} of Transpose[a,{n_{1},n_{2},…}] is the element at position {i_{n1},i_{n2},…} 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,m↔n] or Transpose[a,TwoWayRule[m,n]] is equivalent to Transpose[a,Cycles[{{m,n}}]]. »
- Transpose[a,k] is equivalent to Transpose[a,RotateLeft[Range[n],k]], where n is the depth of a.
- 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. - For a square matrix m, Transpose[m,{1,1}] returns the main diagonal of m, as given by Diagonal[m]. »
- In general, if n
_{p}=n_{q}then the operation Transpose[a,{n_{1},n_{2},…}] is possible for an array a of dimensions {d_{1},d_{2},…} if d_{p}=d_{q}. - Transpose works on SparseArray and structured array objects.

# Examples

open allclose all## Basic Examples (3)

## Scope (13)

### Matrices (6)

Transpose the matrix and format the result:

Transpose a row matrix into a column matrix:

Transpose the column matrix back into a row matrix:

Transposition of a vector leaves it unchanged:

Transpose leaves the identity matrix unchanged:

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:

Format a symbolic transpose in TraditionalForm:

### Arrays (7)

Transpose the first two levels of a rank-3 array, effectively transposing it as a matrix of vectors:

Transpose an array of depth 3 using different permutations:

Cycle levels of a depth-5 array two positions to the right:

Perform transpositions using TwoWayRule notation:

Perform transpositions using Cycles notation:

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

The second and third dimensions have been exchanged:

Get the leading diagonal by transposing two identical levels:

## Applications (13)

### Matrix Decompositions (4)

Find the QRDecomposition of :

is orthogonal, so its inverse is :

Reconstruct from the decomposition:

Compute the SchurDecomposition of a matrix :

The matrix is orthogonal, so its inverse is :

Reconstruct from the decomposition:

Compute the SingularValueDecomposition of a matrix :

The matrices and are orthogonal, so their inverses are their transposes:

Reconstruct from the decomposition:

Construct the singular value decomposition of , a random matrix:

First compute the eigensystem of :

The singular values are the square roots of the nonzero eigenvalues:

The matrix is a diagonal matrix of singular values with the same shape as :

The matrix has the eigenvectors as its columns:

The matrix has columns of the form for each of the nonzero eigenvalues:

### Special Matrices (6)

A symmetric matrix obeys , an antisymmetric matrix . This matrix is symmetric:

Confirm with SymmetricMatrixQ:

Confirm with AntisymmetricMatrixQ:

A matrix is orthogonal if . Check if the matrix is orthogonal:

Confirm that it is orthogonal using OrthogonalMatrixQ:

A real-valued symmetric matrix is orthogonally diagonalizable as , with diagonal and real valued and orthogonal. Verify that the following matrix is symmetric and then diagonalize it:

To diagonalize, first compute 's eigenvalues and place them in a diagonal matrix:

Next, compute the unit eigenvectors:

Then can be diagonalized with as previously, and :

A matrix is unitary if . Show that the matrix is unitary:

Confirm with UnitaryMatrixQ:

A real-valued matrix is called normal if . Normal matrices are the most general kind of matrix that can be unitarily diagonalized as with diagonal and unitary. All real symmetric matrices are normal because both sides of the equality are simply :

Show that the following matrix is normal and then diagonalize it:

Confirm using NormalMatrixQ:

A normal matrix like can be unitarily diagonalized using Eigensystem:

Unlike the case of a symmetric matrix, the diagonal matrix here is complex valued:

Normalizing the eigenvectors and putting them in columns gives a unitary matrix:

Show that real antisymmetric matrices and orthogonal matrices are normal and thus can be unitarily diagonalized. For orthogonal matrices, simply substitute in the definition to get the identity matrix on both sides:

For an antisymmetric matrix, both sides are simply :

Orthogonal matrices have eigenvalues that lie on the unit circle:

### Visualization (3)

Use Transpose to change data grouping in BarChart:

Use Transpose to swap the and axes in ListPlot3D:

This has the effect of reflecting the data across the line :

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

For example, accumulate at all levels of an array:

Reverse at all levels of an array:

Reverse the data at all levels, reflecting across the line and swapping red and blue channels:

## Properties & Relations (18)

Transpose obeys :

For compatible matrices and , Transpose obeys :

Matrix inversion commutes with Transpose, i.e. :

Conjugate[Transpose[m]] can be done in a single step with ConjugateTranspose:

Many special matrices are defined by their properties under Transpose. A symmetric matrix has :

An orthogonal matrix satisfies :

The product of a matrix and its transpose is symmetric:

is the matrix product of and :

The sum of a square matrix and its transpose is symmetric:

The difference is antisymmetric:

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}:

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

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

Take an array with dimensions {2,3,4}:

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

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

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

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

Transpositions do not commute, in general:

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

Transpose and TensorTranspose coincide on explicit arrays:

TensorTranspose further supports symbolic operations that Transpose does not:

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:

## Possible Issues (1)

## Neat Examples (1)

#### Text

Wolfram Research (1988), Transpose, Wolfram Language function, https://reference.wolfram.com/language/ref/Transpose.html (updated 2024).

#### CMS

Wolfram Language. 1988. "Transpose." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Transpose.html.

#### APA

Wolfram Language. (1988). Transpose. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Transpose.html