Given two grids of integers a (shape n x m) and b (shape m x p), return their matrix product:
an n x p grid whose cell at row i, column j is the sum over t of a[i][t] * b[t][j].
Examples
Input: a = [[1, 2],
[3, 4]]
b = [[5, 6],
[7, 8]]
Output: [[19, 22],
[43, 50]]
Input: a = [[1, 2, 3]]
b = [[1],
[2],
[3]]
Output: [[14]]
Constraints
1 <= n, m, p <= 40; the number of columns ofaalways equals the number of rows ofb
Goals
- Implement the row-times-column rule of matrix multiplication
- Get the output dimensions right for non-square inputs