Just like vectors are ordered lists of numbers, matrices are ordered tables of numbers. To work with them effectively, we need a standard way to describe their size and refer to their individual components. This involves understanding matrix dimensions and element notation.
The size, or dimensions, of a matrix are defined by the number of rows and the number of columns it contains. We typically say a matrix with m rows and n columns is an m×n matrix (read as "m by n"). The number of rows always comes first.
For example, consider this matrix A:
A=[5−3120614]Matrix A has 2 rows and 3 columns, so it is a 2×3 matrix.
It's important to remember this order: rows first, then columns. A 3×2 matrix would look different, having 3 rows and 2 columns:
B=135246Here, B is a 3×2 matrix.
Matrices A and B have different dimensions. A is 2×3, while B is 3×2.
We often need to refer to a specific number, or element, within a matrix. We do this using indices, typically represented by subscripts. If we have a matrix A, the element in the i-th row and j-th column is denoted as Aij or aij. Again, the row index (i) comes first, followed by the column index (j).
Let's use matrix A from before:
A=[5−3120614]Here's how we refer to its elements:
Notation Aij specifies the element at row i and column j.
In mathematics and textbooks, indices usually start from 1 (1-based indexing). So, the top-left element is A11. However, in many programming languages, including Python and its library NumPy, indexing starts from 0 (0-based indexing).
A[i, j]
, where i
starts at 0 and j
starts at 0.So, the mathematical element A11 corresponds to A[0, 0]
in NumPy. Similarly, A23 corresponds to A[1, 2]
. We will primarily use the mathematical notation (Aij) when discussing concepts, but it's essential to remember the 0-based indexing when we start implementing these ideas in Python with NumPy in the hands-on sections.
Understanding these conventions allows us to precisely communicate about matrices and their components, which is fundamental as we move towards performing operations with them. When we work with NumPy, we'll see how its array structures directly map to these mathematical concepts, using 0-based indexing for practical access.
© 2025 ApX Machine Learning