I am trying to create a new matrix(array)
JavaScript
x
4
1
a = [1, 2, 3]
2
3
b = [0, 1, 2]
4
where
JavaScript
1
2
1
C = [[1*0, 1*1, 1*2], [2*0, 2*1, 2*2], [3*0, 3*1, 3*2]]
2
I have been scouring the documentation in numpy but can’t find a function to satisfy this.
JavaScript
1
5
1
for i in a:
2
c = np.multiply(a, b)
3
for j in b:
4
c = np.multiply(a, b)
5
Advertisement
Answer
You’re looking for numpy.matmul
. You’ll need to make the vectors have two dimensions (with a size of one in one of the dimensions). For example:
JavaScript
1
2
1
np.matmul(np.array([[1],[2],[3]]), np.array([[2,3,4]]))
2