dpnp.vecmat
- dpnp.vecmat(x1, x2, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True, signature=None, axes=None, axis=None)
Vector-matrix dot product of two arrays.
Given a vector (or stack of vector) \(\mathbf{v}\) in x1 and a matrix (or stack of matrices) \(\mathbf{A}\) in x2, the vector-matrix product is defined as:
\[\mathbf{b} \cdot \mathbf{A} = \sum_{i=0}^{n-1} \overline{v_i}A_{ij}\]where the sum is over the last dimension of x1 and the one-but-last dimensions in x2 (unless axes is specified) and where \(\overline{v_i}\) denotes the complex conjugate if \({v}\) is complex and the identity otherwise. (For a non-conjugated vector-matrix product, use
dpnp.matvec(x2.mT, x1)
.)For full documentation refer to
numpy.vecmat
.- 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 summation axis removed. If not provided or
None
, a freshly-allocated array is used.Default:
None
.dtype ({None, str, dtype object}, optional) --
Type to use in computing the matrix product. By default, the returned array will have data type that is determined by considering Promotion Type Rule and device capabilities.
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"
.axes ({None, list of tuples}, optional) --
A list of tuples with indices of axes the vector-matrix product should operate on. For instance, for the signature of
(i),(i,j)->(j)
, the base elements are 1D vectors and 2D matrices, where the vectors are assumed to be stored in the last axis of the first argument, and the matrices in the last two axes of the second argument. The corresponding axes keyword would be[(-1,), (-2, -1), (-1,)]
.Default:
None
.
- Returns:
out -- The vector-matrix product of the inputs.
- 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.vecdot
Vector-vector product..
dpnp.matvec
Matrix-vector product.
dpnp.matmul
Matrix-matrix product.
dpnp.einsum
Einstein summation convention.
Examples
Project a vector along X and Y.
>>> import dpnp as np >>> v = np.array([0., 4., 2.]) >>> a = np.array([[1., 0., 0.], ... [0., 1., 0.], ... [0., 0., 0.]]) >>> np.vecmat(v, a) array([0., 4., 0.])