# Transpose

In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by A$^T$ (among other notations).
The transpose of a matrix was introduced in 1858 by the British mathematician Arthur Cayley.

## Transpose of a matrix
### Definition

The transpose of a matrix A, denoted by A$^T$, $^⊤$A, A$^⊤$, $A^{\intercal }$, A′, A$^{tr}$, $^t$A or A$^t$, may be constructed by any one of the following methods:
* Reflect A over its main diagonal (which runs from top-left to bottom-right) to obtain A$^T$
* Write the rows of A as the columns of A$^T$
* Write the columns of A as the rows of A$^T$
Formally, the i-th row, j-th column element of A$^T$ is the j-th row, i-th column element of A:
    $\left[\mathbf {A} ^{\operatorname {T} }\right]_{ij}=\left[\mathbf {A} \right]_{ji}.$
If A is an m × n matrix, then A$^T$ is an n × m matrix.
In the case of square matrices, A$^T$ may also denote the Tth power of the matrix A. For avoiding a possible confusion, many authors use left upperscripts, that is, they denote the transpose as $^T$A. An advantage of this notation is that no parentheses are needed when exponents are involved: as ($^T$A)$^n$ = $^T$(A$^n$), notation $^T$A$^n$ is not ambiguous.
In this article, this confusion is avoided by never using the symbol T as a variable name.

#### Matrix definitions involving transposition

A square matrix whose transpose is equal to itself is called a symmetric matrix; that is, A is symmetric if
    $\mathbf {A} ^{\operatorname {T} }=\mathbf {A} .$
A square matrix whose transpose is equal to its negative is called a skew-symmetric matrix; that is, A is skew-symmetric if
    $\mathbf {A} ^{\operatorname {T} }=-\mathbf {A} .$
A square complex matrix whose transpose is equal to the matrix with every entry replaced by its complex conjugate (denoted here with an overline) is called a Hermitian matrix (equivalent to the matrix being equal to its conjugate transpose); that is, A is Hermitian if
    $\mathbf {A} ^{\operatorname {T} }={\overline {\mathbf {A} }}.$
A square complex matrix whose transpose is equal to the negation of its complex conjugate is called a skew-Hermitian matrix; that is, A is skew-Hermitian if
    $\mathbf {A} ^{\operatorname {T} }=-{\overline {\mathbf {A} }}.$
A square matrix whose transpose is equal to its inverse is called an orthogonal matrix; that is, A is orthogonal if
    $\mathbf {A} ^{\operatorname {T} }=\mathbf {A} ^{-1}.$
A square complex matrix whose transpose is equal to its conjugate inverse is called a unitary matrix; that is, A is unitary if
    $\mathbf {A} ^{\operatorname {T} }={\overline {\mathbf {A} ^{-1}}}.$

### Examples

* ${\begin{bmatrix}1&2\end{bmatrix}}^{\operatorname {T} }=\,{\begin{bmatrix}1\\2\end{bmatrix}}$
* ${\begin{bmatrix}1&2\\3&4\end{bmatrix}}^{\operatorname {T} }={\begin{bmatrix}1&3\\2&4\end{bmatrix}}$
* ${\begin{bmatrix}1&2\\3&4\\5&6\end{bmatrix}}^{\operatorname {T} }={\begin{bmatrix}1&3&5\\2&4&6\end{bmatrix}}$

### Properties

Let A and B be matrices and c be a scalar.
* $\left(\mathbf {A} ^{\operatorname {T} }\right)^{\operatorname {T} }=\mathbf {A} .$
    The operation of taking the transpose is an involution (self-inverse).
* $\left(\mathbf {A} +\mathbf {B} \right)^{\operatorname {T} }=\mathbf {A} ^{\operatorname {T} }+\mathbf {B} ^{\operatorname {T} }.$
    The transpose respects addition.
* $\left(c\mathbf {A} \right)^{\operatorname {T} }=c(\mathbf {A} ^{\operatorname {T} }).$
    The transpose of a scalar is the same scalar. Together with the preceding property, this implies that the transpose is a linear map from the space of m × n matrices to the space of the n × m matrices.
* $\left(\mathbf {AB} \right)^{\operatorname {T} }=\mathbf {B} ^{\operatorname {T} }\mathbf {A} ^{\operatorname {T} }.$
    The order of the factors reverses. By induction, this result extends to the general case of multiple matrices, so
       (A$_1$A$_2$...A$_{k−1}$A$_k$)$^T$ = A$_k$$^T$A$_{k−1}$$^T$…A$_2$$^T$A$_1$$^T$.
* $\det \left(\mathbf {A} ^{\operatorname {T} }\right)=\det(\mathbf {A} ).$
    The determinant of a square matrix is the same as the determinant of its transpose.
* The dot product of two column vectors a and b can be computed as the single entry of the matrix product$\mathbf {a} \cdot \mathbf {b} =\mathbf {a} ^{\operatorname {T} }\mathbf {b} .$
* If A has only real entries, then A$^T$A is a positive-semidefinite matrix.
* $\left(\mathbf {A} ^{\operatorname {T} }\right)^{-1}=\left(\mathbf {A} ^{-1}\right)^{\operatorname {T} }.$
    The transpose of an invertible matrix is also invertible, and its inverse is the transpose of the inverse of the original matrix. The notation A$^{−T}$ is sometimes used to represent either of these equivalent expressions.
* If A is a square matrix, then its eigenvalues are equal to the eigenvalues of its transpose, since they share the same characteristic polynomial.
* $\left(\mathbf {A} \mathbf {a} \right)\cdot \mathbf {b} =\mathbf {a} \cdot \mathbf {\left(A^{T}\mathbf {b} \right)}$ for two column vectors $\mathbf {a} ,\mathbf {b}$ and the standard dot product.
* Over any field $k$, a square matrix $\mathbf {A}$ is similar to $\mathbf {A} ^{\operatorname {T} }$.
    This implies that $\mathbf {A}$ and $\mathbf {A} ^{\operatorname {T} }$ have the same invariant factors, which implies they share the same minimal polynomial, characteristic polynomial, and eigenvalues, among other properties.
    A proof of this property uses the following two observations.
*   * Let $\mathbf {A}$ and $\mathbf {B}$ be $n\times n$ matrices over some base field $k$ and let $L$ be a field extension of $k$. If $\mathbf {A}$ and $\mathbf {B}$ are similar as matrices over $L$, then they are similar over $k$. In particular this applies when $L$ is the algebraic closure of $k$.
*   * If $\mathbf {A}$ is a matrix over an algebraically closed field in Jordan normal form with respect to some basis, then $\mathbf {A}$ is similar to $\mathbf {A} ^{\operatorname {T} }$. This further reduces to proving the same fact when $\mathbf {A}$ is a single Jordan block, which is a straightforward exercise.

### Products

If A is an m × n matrix and A$^T$ is its transpose, then the result of matrix multiplication with these two matrices gives two square matrices: A A$^T$ is m × m and A$^T$ A is n × n. Furthermore, these products are symmetric matrices. Indeed, the matrix product A A$^T$ has entries that are the inner product of a row of A with a column of A$^T$. But the columns of A$^T$ are the rows of A, so the entry corresponds to the inner product of two rows of A. If p$_{ij}$ is the entry of the product, it is obtained from rows i and j in A. The entry p$_{ji}$ is also obtained from these rows, thus p$_{ij}$ = p$_{ji}$, and the product matrix (p$_{ij}$) is symmetric. Similarly, the product A$^T$ A is a symmetric matrix.
A quick proof of the symmetry of A A$^T$ results from the fact that it is its own transpose:
    $\left(\mathbf {A} \mathbf {A} ^{\operatorname {T} }\right)^{\operatorname {T} }=\left(\mathbf {A} ^{\operatorname {T} }\right)^{\operatorname {T} }\mathbf {A} ^{\operatorname {T} }=\mathbf {A} \mathbf {A} ^{\operatorname {T} }.$

### Implementation of matrix transposition on computers

On a computer, one can often avoid explicitly transposing a matrix in memory by simply accessing the same data in a different order. For example, software libraries for linear algebra, such as BLAS, typically provide options to specify that certain matrices are to be interpreted in transposed order to avoid the necessity of data movement.
However, there remain a number of circumstances in which it is necessary or desirable to physically reorder a matrix in memory to its transposed ordering. For example, with a matrix stored in row-major order, the rows of the matrix are contiguous in memory and the columns are discontiguous. If repeated operations need to be performed on the columns, for example in a fast Fourier transform algorithm, transposing the matrix in memory (to make the columns contiguous) may improve performance by increasing memory locality.
Ideally, one might hope to transpose a matrix with minimal additional storage. This leads to the problem of transposing an n × m matrix in-place, with O(1) additional storage or at most storage much less than mn. For n ≠ m, this involves a complicated permutation of the data elements that is non-trivial to implement in-place. Therefore, efficient in-place matrix transposition has been the subject of numerous research publications in computer science, starting in the late 1950s, and several algorithms have been developed.

## Transposes of linear maps and bilinear forms

As the main use of matrices is to represent linear maps between finite-dimensional vector spaces, the transpose is an operation on matrices that may be seen as the representation of some operation on linear maps.
This leads to a much more general definition of the transpose that works on every linear map, even when linear maps cannot be represented by matrices (such as in the case of infinite dimensional vector spaces). In the finite dimensional case, the matrix representing the transpose of a linear map is the transpose of the matrix representing the linear map, independently of the basis choice.

### Transpose of a linear map

Let X$^#$ denote the algebraic dual space of an R-module X. Let X and Y be R-modules. If u : X → Y is a linear map, then its algebraic adjoint or dual, is the map u$^#$ : Y$^#$ → X$^#$ defined by f ↦ f ∘ u. The resulting functional u$^#$(f) is called the pullback of f by u. The following relation characterizes the algebraic adjoint of u
    ⟨u$^#$(f), x⟩ = ⟨f, u(x)⟩ for all f ∈ Y$^#$ and x ∈ X
where ⟨•, •⟩ is the natural pairing (i.e. defined by ⟨h, z⟩ := h(z)). This definition also applies unchanged to left modules and to vector spaces.
The definition of the transpose may be seen to be independent of any bilinear form on the modules, unlike the adjoint (below).
The continuous dual space of a topological vector space (TVS) X is denoted by X'. If X and Y are TVSs then a linear map u : X → Y is weakly continuous if and only if u$^#$(Y') ⊆ X', in which case we let $^t$u : Y' → X' denote the restriction of u$^#$ to Y'. The map $^t$u is called the transpose of u.
If the matrix A describes a linear map with respect to bases of V and W, then the matrix A$^T$ describes the transpose of that linear map with respect to the dual bases.

### Transpose of a bilinear form

Every linear map to the dual space u : X → X$^#$ defines a bilinear form B : X × X → F, with the relation B(x, y) = u(x)(y). By defining the transpose of this bilinear form as the bilinear form $^t$B defined by the transpose $^t$u : X$^{##}$ → X$^#$ i.e. $^t$B(y, x) = $^t$u(Ψ(y))(x), we find that B(x, y) = $^t$B(y, x). Here, Ψ is the natural homomorphism X → X$^{##}$ into the double dual.

### Adjoint

If the vector spaces X and Y have respectively nondegenerate bilinear forms B$_X$ and B$_Y$, a concept known as the adjoint, which is closely related to the transpose, may be defined:
If u : X → Y is a linear map between vector spaces X and Y, we define g as the adjoint of u if g : Y → X satisfies
    $B_{X}{\bigx,g(y){\big )}=B_{Y}{\bigu(x),y{\big )}$ for all x ∈ X and y ∈ Y.
These bilinear forms define an isomorphism between X and X$^#$, and between Y and Y$^#$, resulting in an isomorphism between the transpose and adjoint of u. The matrix of the adjoint of a map is the transposed matrix only if the bases are orthonormal with respect to their bilinear forms. In this context, many authors however, use the term transpose to refer to the adjoint as defined here.
The adjoint allows us to consider whether g : Y → X is equal to u$^{−1}$ : Y → X. In particular, this allows the orthogonal group over a vector space X with a quadratic form to be defined without reference to matrices (nor the components thereof) as the set of all linear maps X → X for which the adjoint equals the inverse.
Over a complex vector space, one often works with sesquilinear forms (conjugate-linear in one argument) instead of bilinear forms. The Hermitian adjoint of a map between such spaces is defined similarly, and the matrix of the Hermitian adjoint is given by the conjugate transpose matrix if the bases are orthonormal.