It is often useful to switch the rows and columns of a matrix around. The resulting matrix is called the transpose of the original matrix, and denoted with a superscript ⊤ or an apostrophe ′:
M=34−12−12M⊤=[324−1−12]
Note that Mij=Mji⊤, and that if M is an r×c matrix, M⊤ is a c×r matrix.
Addition
There are two kinds of addition operations for matrices. The first is scalar addition:
M+2=3+24+2−1+22+2−1+22+2=561414
The other kind is matrix addition:
M+M=34−12−12+34−12−12=68−24−24
Formally, (A+B)ij=Aij+Bij.
Note that only matrices of the same dimension can be added to each other – there is no such thing as adding a 4×5 matrix to a 2×9 matrix.
Multiplication
There are also two common kinds of multiplication for matrices. The first is scalar multiplication:
4M=434−12−12=1216−48−48
Formally, (cM)ij=cMij.
The other kind is matrix multiplication. The product of two matrices, AB, is defined by multiplying all of A’s rows by B’s columns in the following manner:
(AB)ik=j∑AijBjk
[142−110]30−12−12=[21229]
Note that matrix multiplication is only defined if the number of columns of A matches the number of rows of B, and that if A is an m×n matrix and B is an n×p matrix, then AB is an m×p matrix.
The following elementary algebra rules carry over to matrix algebra:
One important exception, however, is that AB=BA; the order of matrix multiplication matters, and we must remember to, for instance, “left multiply” both sides of an equation by a matrix M to preserve equality.
Inner and outer products
Suppose u and v are two n×1 vectors. We can’t multiply them in the sense defined above, uv, because the number of columns of u, 1, doesn’t match the number of rows of v, n. However, there are two ways in which vectors of the same dimension can be multiplied.
The first is called the inner product (also, the “cross product”):
u⊤v[32][2−1]=j∑ujvj=6−2=4.
Note that when we multiply matrices, the element (AB)ij is equal to the inner product of the ith row of A and the jth column of B.
The second way of multiplying two vectors is called the outer product:
(uv⊤)ij[32][2−1]=uivj=[64−3−2]
Note that the inner product returns a scalar number, while the outer product returns an n×n matrix.