I have a numpy question
I have a 2D array of values
vals=np.array([[1.0, 2.0, 3.0],[4.0, 5.0, 6.0],[7.0, 8.0, 9.0]], np.float32)
And a 2D array of scale factors
factors=np.array([[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]])
I want to multiply every row in vals with every row in factors to end up with a "scaled_vals" array like the one below NOTE : This output has been corrected form my original post - my apologies for this goof up
[[ 1. 2. 3.]
[ 8. 10. 12.]
[21. 24. 27.]]
[[ 4. 8. 12.]
[20. 25. 30.]
[42. 48. 54.]]
I'm showing factors with just two columns of data but in actuality it is 'n'.
Any help will be gratefully received.
Doug
===
copied from the comment:
for step in range(2):
scaled_vals = np.multiply(vals, factors[0:,step:step+1])