Daily Data Science Puzzle
import numpy as np
# graphics data
a = [[1, 1],
# stretch vectors
b = [[2, 0],
c = np.matmul(a, b)
What is the output of this puzzle?
Numpy is a popular Python library for data science focusing on arrays, vectors, and matrices.
This puzzle shows an important application domain of matrix multiplication: Computer Graphics.
We create two matrices a and b. The first matrix a is the data matrix (e.g. consisting of two column vectors
(1,0)). The second matrix b is the transformation matrix that transforms the input data. In our setting, the transformation matrix simply stretches the column vectors.
More precisely, the two column vectors
(1,0) are stretched by factor 2 to
(2,0). The resulting matrix is therefore
[[2,2],[2,0]]. We access the first row and second column.
Are you a master coder?
Test your skills now!