Hello, Grunt!
Someone taught you a very messy way of multiplying matrices.
. . Shame on them!
ThePerfectHacker referred to a "standard dot product".
. . I thought everyone used it.
Let's multiply "a row times a column". Code:
| 4 |
[ 1 2 3 ] · | 5 | = (1)(4) + (2)(5) + (3)(6)
| 6 |
= 4 + 10 + 18 = 32
I hope you see what pairs are being multipled.
Your problem looks like this: Code:
| 3 1 |
| 1 0 2 | | |
| | · | 2 1 |
| -1 3 1 | | |
| 1 0 |
We will multiply each row in the first matrix
. . by each column in the second matrix.
Here we go . . .
Row-1 times Column-1 Code:
| 3 |
| 1 0 2 | · | 2 | = (1)(3) + (0)(2) + (2)(1) = 5
| 1 |
Where does this answer go?
In Row-1, Column-1 of the product matrix (upper left).
Row-1 times Column-2 Code:
| 1 |
| 1 0 2 | · | 1 | = (1)(1) + (0)(1) + (2)(0) = 1
| 0 |
This goes in Row-1, Column-2 of the product (upper right).
Row-2 times Column-1 Code:
| 3 |
|-1 3 1 | · | 2 | = (-1)(3) + (3)(2) + (1)(1) = 4
| 1 |
This goes in Row-2, Column-1 of the product (lower left).
Row-2 times Column-2 Code:
| 1 |
|-1 3 1 | · | 1 | = (-1)(1) + (3)(1) + (1)(0) = 2
| 0 |
This goes in Row-2, Column-2 of the product (lower right).
Answer: