What is an efficient way to multliply two numpy arrays together? For example, given
A = [1, 2, 3, 4]
B = [2, 3, 5, 7]
I want to calculate the dot product between A and B, which is
A.B/|A||B| = (1*2 + 2*3 + .. 4*7)/sqrt(1^2 + 2^2... +4^2) * sqrt(.....)
How can I do this efficiently and fast?
If you are using numpy, numpy.dot would do the Job for you
The Fastest norm for a vector would be
and here is the comparison with other methods