Multiplying numpy 2d Array with 1d Array

Viewed 3908

I have a numpy 2d array:

[[1,1,1],
[1,1,1],
[1,1,1],
[1,1,1]]

How can I get it so that it multiplies the indices from top to bottom with the corresponding values from a 1d array when the row length of the 2d array is smaller than length of 1d array ? For example multiply above with this:

[10, 20, 30, 40]

to get this:

 [[10, 10, 10],
 [20, 20, 20],
 [30, 30, 30]
 [40, 40, 40]]

Probably a duplicate, but I couldnt find exact thing I am looking for. Thanks in advance.

1 Answers
Related