dpnp.vecdot¶
- dpnp.vecdot(x1, x2, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True, signature=None, axes=None, axis=None)[source]¶
Computes the vector dot product.
Let \(\mathbf{a}\) be a vector in x1 and \(\mathbf{b}\) be a corresponding vector in x2. The dot product is defined as:
\[\mathbf{a} \cdot \mathbf{b} = \sum_{i=0}^{n-1} \overline{a_i}b_i\]where the sum is over the last dimension (unless axis is specified) and where \(\overline{a_i}\) denotes the complex conjugate if \(a_i\) 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{None, "C", "F", "A", "K"}, 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 inaxes=[(axis,), (axis,), ()].Default:
None.
- Returns:
- outdpnp.ndarray
The vector dot product of the inputs. This is a 0-d array only when both x1, x2 are 1-d vectors.
Limitations
Keyword arguments subok, and signature are only supported with their default values. Otherwise
NotImplementedErrorexception will be raised.See also
dpnp.linalg.vecdotArray API compatible version.
dpnp.vdotComplex-conjugating dot product but flattens arguments first.
dpnp.matmulMatrix-matrix product.
dpnp.vecmatVector-matrix product.
dpnp.matvecMatrix-vector product.
dpnp.einsumEinstein 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.])