Transposition swaps a matrix’s row and column indices. For an m×n matrix A, its transpose Aᵀ is n×m, with Aᵀ[i,j] = A[j,i]. A value at row 0, column 6 therefore moves to row 6, column 0. A column vector becomes a row vector, making vector transposition a special case of matrix transposition. section 2.5.1
Geometrically, transposition can reorganize an image matrix by exchanging its height and width, as when a 4×9 image representation becomes 9×4. In multiplication, transposition reverses the order of factors: (AB)ᵀ = BᵀAᵀ. This also connects dot products with matrix multiplication, since one vector can be transposed before multiplying by the other. section 2.5.1 section 2.5.3
Transposition supports several linear-algebra constructions:
- For an orthogonal rotation matrix R, Rᵀ = R⁻¹; transposing reverses the rotation and preserves vector length. section 2.14.2
- Multiplying a linear system by Aᵀ produces AᵀA, a square matrix used in the pseudo-inverse expression (AᵀA)⁻¹Aᵀ. section 2.12.4
- For symmetric matrices, an eigenvector matrix S is orthogonal, so S⁻¹ = Sᵀ and diagonalization can be written A = SΛSᵀ. section 2.15
Transposing a matrix in PyTorch
Create a matrix I₄₉, transpose its dimensions with torch.transpose(I₄₉, 0, 1), and verify that every original element satisfies I₄₉[i][j] == I₄₉_t[j][i]. PyTorch’s .T notation produces the same result. section 2.7.1
Listing 2.5 Transpose
I49 = torch.stack([torch.arange(0, 72, 8), torch.arange(64, 136, 8), #1
torch.arange(128, 200, 8), torch.arange(192, 264, 8)])
I49_t = torch.transpose(I49, 0, 1) #2
for i in range(0, I49.shape[0]):
for j in range(0, I49.shape[1]):
assert I49[i][j] == I49_t[j][i] #3
assert torch.allclose(I49_t, I49.T, 1e-5) #4
Inspect the complete PyTorch listing for constructing, transposing, and checking a matrix. section 2.7.1





