[Tutor] Python 3.6 Multiply the elements of a 2D Array by the elements of a 1D Aeeay
Peter Otten
__peter__ at web.de
Fri Apr 14 04:21:13 EDT 2017
Stephen P. Molnar wrote:
> However, what I want to do is multiply each element ob D by each element
> of s and sum all of the products.
If you *really* want this:
sum_of_all_products = s.sum() * D.sum()
example:
s = [a b c]
D = [[a1 a2]
[a3 a4]]
a*a1 + a*a2 + a*a3 + a*a4 = a * D.sum()
d := D.sum()
a*d + b*d + c*d = s.sum() * d
Even if that's what you want you should heed Steven's advice.
More information about the Tutor
mailing list