elementwise_dot

halotools.utils.elementwise_dot(x, y)[source] [edit on github]

Calculate the dot product between each pair of elements in two input lists of n-dimensional points.

Parameters:
x : ndarray

Numpy array of shape (npts, ndim) storing a collection of n-dimensional vectors

y : ndarray

Numpy array of shape (npts, ndim) storing a collection of n-dimensional vectors

Returns:
result : ndarray

Numpy array of shape (npts, ) storing the dot product between each pair of corresponding vectors in x and y.

Examples

Let’s create two sets of semi-random 3D vectors, x1 and x2.

>>> npts = int(1e3)
>>> ndim = 3
>>> x1 = np.random.random((npts, ndim))
>>> x2 = np.random.random((npts, ndim))

We then can find the dot product between each pair of vectors in x1 and x2.

>>> dots = elementwise_dot(x1, x2)