numpy.vecmat#
- numpy.vecmat(x1,x2,/,out=None,*,casting='same_kind',order='K',dtype=None,subok=True[,signature,axes,axis])=<ufunc'vecmat'>#
Vector-matrix dot product of two arrays.
Given a vector (or stack of vector)\(\mathbf{v}\) in
x1anda matrix (or stack of matrices)\(\mathbf{A}\) inx2, thevector-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
x1and the one-but-lastdimensions inx2(unlessaxes is specified) and where\(\overline{v_i}\) denotes the complex conjugate if\(v\)is complex and the identity otherwise. (For a non-conjugated vector-matrixproduct, usenp.matvec(x2.mT,x1).)New in version 2.2.0.
- Parameters:
- x1, x2array_like
Input arrays, scalars not allowed.
- outndarray, optional
A location into which the result is stored. If provided, it must havethe broadcasted shape of
x1andx2with the summation axisremoved. If not provided or None, a freshly-allocated array is used.- **kwargs
For other keyword-only arguments, see theufunc docs.
- Returns:
- yndarray
The vector-matrix product of the inputs.
- Raises:
- ValueError
If the last dimensions of
x1and the one-but-last dimension ofx2are not the same size.If a scalar value is passed in.
See also
Examples
Project a vector along X and Y.
>>>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.])