python - Numpy and dot products of multiple vector pairs: how can it be done? -
i want dot product of n vector pairs (a_vec[i, :], b_vec[i, :]).
a_vec has shape [n, 3], bvec has same shape (n 3d vectors).
i know can done in cycle via numpy.dot function. cannot done somehow simpler , faster?
np.einsum it:
np.einsum('ij,ij->i', a_vec, b_vec)
Comments
Post a Comment