← Problems

3. Matrix Multiply

EasyMatricesLinear AlgebraNumPy

Implement matrix multiplication for two 2D matrices AA and BB.

Given ARm×kA \in \mathbb{R}^{m \times k} and BRk×nB \in \mathbb{R}^{k \times n}, compute:

Cij=l=1kAilBljC_{ij} = \sum_{l=1}^{k} A_{il} \cdot B_{lj}

The result CC has shape m×nm \times n.

Example

A = [[1, 2], B = [[5, 6], [3, 4]] [7, 8]] Output: [[19, 22], [43, 50]]

Constraints

  • Inputs are given as lists of lists (not NumPy arrays), but you may convert internally.
  • You may assume the dimensions are compatible for multiplication.
Python 3
⌘ + Enter
Run your code to see results
Ctrl + Enter