I have an n
-by-3
-by-3
numpy array A
and an n
-by-3
numpy array B
. I'd now like to multiply every row of every one of the n
3
-by-3
matrices with the corresponding scalar in B
, i.e.,
import numpy as np
A = np.random.rand(10, 3, 3)
B = np.random.rand(10, 3)
for a, b in zip(A, B):
a = (a.T * b).T
print(a)
Can this be done without the loop as well?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…