multiply 2 vectors with different length such that first vector is multiplied with each element of the second vector

Viewed 27

How can I use numpy multiply 2 1-Dim vector with different length such that first vector is multiplied with each element of the second vector

A = np.array(
    [1, 2]
)
B = np.array(
    [10, 20, 30]
)

# expected result
np.array(
    [10, 20], # 10 * [1, 2]
    [20, 40], # 20 * [1, 2]
    [30, 60] # 30 * [1, 2]
)
0 Answers
Related