A number of operations can be performed on matrices. We first describe some of the more common ones and provide examples as a review of matrix arithmetic.
Addition and Subtraction
Two
matrices can be added or subtracted to create a third matrix. When adding two matrices, corresponding elements are summed as illustrated here.
Subtraction is performed in a similar fashion but the corresponding elements are subtracted instead of summed.
Multiplication
Matrix multiplication is only defined for matrices where the number of columns in the matrix on the lefthand side is equal to the number of rows in the matrix on the righthand side. The result is a new matrix that contains the same number of rows as the matrix on the lefthand side and the same number of columns as the matrix on the righthand side. In other words, given a matrix of size multiplied by a matrix of size , the resulting matrix is of size .
In multiplying two matrices, each element of the new matrix is the result of summing the product of a row in the lefthand side matrix by a column in the righthand side matrix. In the example matrix multiplication illustrated here, the row and column used to compute entry (0,0) of the new matrix is shaded in light blue.
Viewing matrix multiplication based on the element subscripts can help you to better understand the operation. Consider the two matrices from above and assume they are labeled A and B, respectively.
The computation of the individual elements resulting from multiplying A and B (C = A * B
) is performed as follows:
resulting in
Scaling
A matrix can be uniformly scaled, which modifies each element of the matrix by the same scale factor. A scale factor of less than 1 has the effect of reducing the value of each element whereas a scale factor greater than 1 increases the value of each element. Scaling a matrix by a scale factor of 3 is illustrated here:
Transpose
Another useful operation that can be applied to a matrix is the matrix transpose. Given a matrix, a transpose swaps the rows and columns to create a new matrix of size as illustrated here: