Matrix-vector dot product of two arrays.
Given a matrix (or stack of matrices) \(\mathbf{A}\) in x1 and a vector (or stack of vectors) \(\mathbf{v}\) in x2, the matrix-vector product is defined as:
where the sum is over the last dimensions in x1 and x2 (unless axes is specified). (For a matrix-vector product with the vector conjugated, use np.vecmat(x2, x1.mT).)
New in version 2.2.0.
Input arrays, scalars not allowed.
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.
For other keyword-only arguments, see the ufunc docs.
The matrix-vector product of the inputs.
If the last dimensions of x1 and x2 are not the same size.
If a scalar value is passed in.
See also
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.]])
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.matvec.html