Skip to content

Instantly share code, notes, and snippets.

@varepsilon
Created May 6, 2012 09:16
Show Gist options
  • Save varepsilon/2621186 to your computer and use it in GitHub Desktop.
Save varepsilon/2621186 to your computer and use it in GitHub Desktop.
numpy.array scalar product
# 1
sum(x * y for x in a for y in b)
# 2
sum([x * y for x in a for y in b])
# 3
a * b
# 4
numpy.dot(a, b)
# 5
sum(a * b)
# 6
a * numpy.transpose(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment