numpy.matvec#
- numpy.matvec(x1,x2,/,out=None,*,casting='same_kind',order='K',dtype=None,subok=True[,signature,axes,axis])=<ufunc'matvec'>#
Matrix-vector dot product of two arrays.
Given a matrix (or stack of matrices)\(\mathbf{A}\) in
x1anda vector (or stack of vectors)\(\mathbf{v}\) inx2, thematrix-vector product is defined as:\[\mathbf{A} \cdot \mathbf{b} = \sum_{j=0}^{n-1} A_{ij} v_j\]where the sum is over the last dimensions in
x1andx2(unlessaxesis specified). (For a matrix-vector product with thevector conjugated, usenp.vecmat(x2,x1.mT).)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 matrix-vector product of the inputs.
- Raises:
- ValueError
If the last dimensions of
x1andx2are not the same size.If a scalar value is passed in.
See also
Examples
Rotate a set of vectors from Y to X along Z.
>>>a=np.array([[0.,1.,0.],...[-1.,0.,0.],...[0.,0.,1.]])>>>v=np.array([[1.,0.,0.],...[0.,1.,0.],...[0.,0.,1.],...[0.,6.,8.]])>>>np.matvec(a,v)array([[ 0., -1., 0.], [ 1., 0., 0.], [ 0., 0., 1.], [ 6., 0., 8.]])