What I want is really simple but I can't figure out how to do it on numpy.
I have the following matrix:
M = [[1, 1, 1],
[1, 1, 1],
[1, 1, 1]]
And this array:
A = [1, 2, 3]
I want to multiply the matrix with each element on the array on a way to produce:
[[[1, 1, 1],
[1, 1, 1],
[1, 1, 1]],
[[2, 2, 2],
[2, 2, 2],
[2, 2, 2]],
[[3, 3, 3],
[3, 3, 3],
[3, 3, 3]]]
without any for loops, I want just a numpy function.
np.array([M*i for i in A])perhaps?Ato the size ofMfor element-wise operations. Rather, you want your output shape to be the product of the two sizes.forloop.