dpnp.dot

dpnp.dot(a, b, out=None)[source]

Dot product of a and b.

For full documentation refer to numpy.dot.

Parameters:
  • a ({dpnp.ndarray, usm_ndarray, scalar}) -- First input array. Both inputs a and b can not be scalars at the same time.

  • b ({dpnp.ndarray, usm_ndarray, scalar}) -- Second input array. Both inputs a and b can not be scalars at the same time.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Alternative output array in which to place the result. It must have the same shape and data type as the expected output and should be C-contiguous. If these conditions are not met, an exception is raised, instead of attempting to be flexible.

Returns:

out -- Returns the dot product of a and b. If out is given, then it is returned.

Return type:

dpnp.ndarray

See also

dpnp.ndarray.dot

Equivalent method.

dpnp.tensordot

Sum products over arbitrary axes.

dpnp.vdot

Complex-conjugating dot product.

dpnp.einsum

Einstein summation convention.

dpnp.matmul

Matrix product of two arrays.

dpnp.linalg.multi_dot

Chained dot product.

Examples

>>> import dpnp as np
>>> a = np.array([1, 2, 3])
>>> b = np.array([1, 2, 3])
>>> np.dot(a, b)
array(14)

Neither argument is complex-conjugated:

>>> np.dot(np.array([2j, 3j]), np.array([2j, 3j]))
array(-13+0j)

For 2-D arrays it is the matrix product:

>>> a = np.array([[1, 0], [0, 1]])
>>> b = np.array([[4, 1], [2, 2]])
>>> np.dot(a, b)
array([[4, 1],
       [2, 2]])
>>> a = np.arange(3 * 4 * 5 * 6).reshape((3, 4, 5, 6))
>>> b = np.arange(3 * 4 * 5 * 6)[::-1].reshape((5, 4, 6, 3))
>>> np.dot(a, b)[2, 3, 2, 1, 2, 2]
array(499128)
>>> sum(a[2, 3, 2, :] * b[1, 2, :, 2])
array(499128)