11.2 MATRIX MULTIPLICATION ALGORITHM
Assume we are given two compatible matrices M2 and M3 of dimensions I × K and K × J, respectively. Their product is matrix M1 of dimension I × J. The matrix multiplication algorithm can be expressed as
This equation can be expressed in any serial algorithm (i.e., any computer code) as three nested loops. An outer loop iterates over the index i; the next inner loop iterates over the index j. The innermost loop iterates over the index k.
Variable M1 in the above equation is an output variable, while variables M2 and M3 are input variables. The above matrix multiplication algorithm has three indices: i, j, and k, and we can think of these indices as coordinates of a point in a 3-D volume. We organize our indices in the form of a vector:
(11.2)
![]()
for given values of the indices, the vector corresponds to a point in the Z3 space [9].
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access