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.

Default: None.

Returns:
outdpnp.ndarray

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

Warning

Calling the function when a has 2 or more dimensions and b has more than 2 dimensions is deprecated and will eventually raise an error, because the leading dimensions of b end up in the middle of the result. Use dpnp.tensordot(a, b, axes=(-1, -2)) for the same result, or dpnp.matmul for batched matrix multiplication.

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]])