Matrix Dimensions and Entries
Matrix–Vector Multiplication
Matrices and their dimensions
A matrix is a rectangular arrangement of numbers. An m×n matrix has m rows and n columns:
m gives the number of rows.
n gives the number of columns.
The matrix contains mn entries in total.
A general m×n matrix A can be written as
The subscript in aij identifies an entry’s location: i is its row number, and j is its column number. For example, a23 is the entry in row 2, column 3.
When a matrix can multiply a vector
For a matrix–vector product Ax to be defined, the vector x must have the same number of components as A has columns. Thus, if A is m×n, then x must have n components and can be written as
The product Ax is then a vector with m components—one for each row of A:
The matching inner dimensions, both n, are required for the multiplication to be defined. The resulting vector’s number of entries matches the matrix’s number of rows.
Definition by rows: each output is a dot product
To calculate Ax, take each row of A, multiply its entries by the corresponding entries of x, and add the products. The first output component is
The next output component is calculated from the second row, and the process continues through all m rows. In general,
Each output component is a dot product: it is the sum of the products of corresponding entries in a matrix row and the vector x.
Writing rows using transposes
A vector is often written as a column. The transpose changes rows into columns and columns into rows. If the entries of row i are collected into a column vector ai, then the row itself is aiT. Consequently, the ith component of the product can be expressed as
This notation describes matrix–vector multiplication as taking the dot product of each row of A with x.
Worked example
Consider the matrix and vector
The matrix has four columns, so the vector must have four components; this product is therefore defined. Since the matrix has two rows, the result will have two components.
The first component comes from the first row:
The second component comes from the second row:
Therefore,
Definition by columns: a linear combination
Matrix–vector multiplication can also be understood using the columns of the matrix. Suppose an m×n matrix is written as
where each vj is a column vector with m entries. For
the product is
Thus, the entries of x serve as weights for the columns of A. The product is a linear combination of those columns: each column is multiplied by its corresponding component of x, and the resulting vectors are added.
Example of the column interpretation
Consider
The four columns are
The product can be written as
Each component of x determines how much its corresponding column contributes to the resulting vector.
Two complementary ways to understand Ax
Row viewpoint: Each component of Ax is the dot product of one row of A with x.
Column viewpoint: The entire product is a linear combination of the columns of A, weighted by the components of x.
Both viewpoints describe the same matrix–vector multiplication. The row viewpoint emphasizes how each output component is calculated; the column viewpoint emphasizes how the input vector selects and combines the matrix’s columns.

Ask anything
We've read this whole study set, so questions about it get the best answers.