Flip a matrix across its diagonal and its rows become its columns. Watch a grid of two rows turn into a grid of two columns.
Flipping a matrix
The transpose turns every row into a column.
A = [1 2 3; 0 4 5]: 2 rows of 3 cells.
Describe this picture
The matrix drawn as two rows of three cells, each cell shaded by its number and labelled with it. A dashed line marks the diagonal from the top-left cell. The cells swing across that line, each passing through it like a card turned over, and the grid becomes three rows of two, labelled : over over . Then the product appears beside it as a grid, gets its own dashed diagonal, and flips across it in the same way. Every cell lands on a cell with the same number, so the grid comes back unchanged, and its label reads . The picture has no control.
Rows become columns
The flip in the picture at the top of the page is the transpose. The transpose of , written , has the rows of as its columns:
The entry in row and column of is the entry in row and column of :
So an matrix has an transpose. The numbers on the diagonal, where , stay where they are. Transpose twice and you are back where you started.
A vector is a column, so its transpose is a row. That gives a short way to write the dot product of Length and the dot product: a row times a column is one number, the sum of the matching products.
The product rule reverses
What is the transpose of a product? Take the matrices of Matrix multiplication, and . Their product is , so
The order reverses, as it did for inverses in The inverse matrix:
Here is why. Entry of is entry of : row of times column of . Row of is column of , and column of is row of . So it is row of times column of , which is entry of . The shapes agree too: if is and is , then is , and both and are .
The rule has a useful form with vectors. Since ,
A matrix can move from one side of a dot product to the other, if it is transposed on the way. Check it with , and : and ; and .
Symmetric matrices
A matrix that equals its own transpose, , is symmetric: the numbers on each side of the diagonal mirror each other. is symmetric; is not.
One way to make a symmetric matrix always works. For any , the product is symmetric, because by the product rule
That is the second flip in the picture. For the matrix at the top, the columns are , and , and entry of is the dot product of column with column :
Column dotted with column is the same as column dotted with column , which is the symmetry in plain words. The other product, , holds the dot products of the rows, and it is symmetric too.
Permutations
A permutation matrix reorders the entries of a vector. It is the identity matrix with its rows in a new order. Here is one that moves every entry down one place, and the last entry round to the top:
That is a cyclic shift. Another one reverses the order. I’ll call it , the exchange matrix:
Watch both act on a short signal of three samples.
Shift and flip
A permutation matrix reorders the entries of a vector.
x = (a, b, c), three samples, and the permutation matrix P: one 1 in every row and every column.
Describe this picture
The grid of , with its three 1s shaded, then a column of three cells, , and , labelled , and an empty column labelled . For each 1 in an arrow draws from the entry it picks to the place it fills, and the entries slide along the arrows: the new column reads , , . Then changes into , with its 1s on the other diagonal, the new column empties, and the same happens again: it reads , , . The picture has no control.
How do you undo a permutation? Put every entry back where it came from. That is the transpose:
The reason is short. The columns of are the unit vectors in some order. Entry of is column dotted with column : 1 when they are the same unit vector and 0 when they are not. For the cyclic shift, shifts the other way: goes to . The flip undoes itself: , and .
There are permutation matrices of size , one for each order of three things.
Be careful not to stretch the rule. For a permutation the transpose is the inverse, but for most matrices it is not. The matrix has transpose and inverse , two different matrices.
Worked example
- A shape. The transpose of a matrix is .
- Two products. For : and , both symmetric.
- The product rule. For and , .
- Shapes of a product. is and is : is .
- A cyclic shift. sends to , and sends it back.
- A flip. sends to , and again sends it back.
- Predict. Is symmetric for every , even one that is not square? Yes: its transpose is itself.
Where you’ll meet this
The product is at the heart of fitting a line or curve to data, on the page Least squares. The same product, built from data with the averages removed, and divided by a count, gives the covariance matrices of statistics.
The FFT reorders its input with a permutation called bit reversal. For 8 samples it takes them in the order 0, 4, 2, 6, 1, 5, 3, 7. A ring buffer, the circular store that real-time audio programs use for the latest samples, is a cyclic shift in action.
In signal processing · shift and flip matrices
A signal of samples is a vector, and shifting or reversing it is a permutation matrix. The page Shifting, reversing and scaling time moves signals this way, and Properties of the DFT uses the circular shift, which is the cyclic above. One difference in counting: matrix and vector entries count from 1, while samples count from 0. So the vector’s entry is the sample , and here is , , .
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Transpose | rows become columns; becomes | |
| Dot product | a row times a column | |
| Product | reverse order | |
| Moving a matrix | transpose on the way | |
| Symmetric | always is | |
| Permutation | the identity with its rows reordered | |
| Cyclic shift | undone by | |
| Flip | : |