dpnp.vecdot

dpnp.vecdot(x1, x2, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True, signature=None, axes=None, axis=None)

Computes the vector dot product.

Let a be a vector in x1 and b be a corresponding vector in x2. The dot product is defined as:

ab=i=0n1aibi

where the sum is over the last dimension (unless axis is specified) and where ai denotes the complex conjugate if ai is complex and the identity otherwise.

For full documentation refer to numpy.vecdot.

Parameters:
  • x1 ({dpnp.ndarray, usm_ndarray}) -- First input array.

  • x2 ({dpnp.ndarray, usm_ndarray}) -- Second input array.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) --

    A location into which the result is stored. If provided, it must have the broadcasted shape of x1 and x2 with the last axis removed. If not provided or None, a freshly-allocated array is used.

    Default: None.

  • casting ({"no", "equiv", "safe", "same_kind", "unsafe"}, optional) --

    Controls what kind of data casting may occur.

    Default: "same_kind".

  • order ({"C", "F", "A", "K", None}, optional) --

    Memory layout of the newly output array, if parameter out is None.

    Default: "K".

  • dtype ({None, str, dtype object}, optional) --

    Type to use in computing the vector dot product. By default, the returned array will have data type that is determined by considering Promotion Type Rule and device capabilities.

    Default: None.

  • axes ({None, list of tuples}, optional) --

    A list of tuples with indices of axes the dot product should operate on. For instance, for the signature of (i),(i)->(), the base elements are vectors and these are taken to be stored in the last axes of each argument. The corresponding axes keyword would be [(-1,), (-1,), ()].

    Default: None.

  • axis ({None, int}, optional) --

    Axis over which to compute the dot product. This is a short-cut for passing in axes with entries of (axis,) for each single-core-dimension argument and () for all others. For instance, for a signature (i),(i)->(), it is equivalent to passing in axes=[(axis,), (axis,), ()].

    Default: None.

Returns:

out -- The vector dot product of the inputs. This is a 0-d array only when both x1, x2 are 1-d vectors.

Return type:

dpnp.ndarray

Limitations

Keyword arguments subok, and signature are only supported with their default values. Otherwise NotImplementedError exception will be raised.

See also

dpnp.linalg.vecdot

Array API compatible version.

dpnp.vdot

Complex-conjugating dot product but flattens arguments first.

dpnp.matmul

Matrix-matrix product.

dpnp.vecmat

Vector-matrix product.

dpnp.matvec

Matrix-vector product.

dpnp.einsum

Einstein summation convention.

Examples

Get the projected size along a given normal for an array of vectors.

>>> import dpnp as np
>>> v = np.array([[0., 5., 0.], [0., 0., 10.], [0., 6., 8.]])
>>> n = np.array([0., 0.6, 0.8])
>>> np.vecdot(v, n)
array([ 3.,  8., 10.])