This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / matvec

ufunc

numpy:matvec

source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/__init__.py

Summary

Matrix-vector dot product of two arrays.

Extended Summary

Given a matrix (or stack of matrices) in x1 and a vector (or stack of vectors) 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).)

Parameters

x1, x2 : array_like

Input arrays, scalars not allowed.

out : 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.

**kwargs

For other keyword-only arguments, see the ufunc docs <ufuncs.kwargs>.

Returns

y : ndarray

The matrix-vector product of the inputs.

Raises

: ValueError

If the last dimensions of x1 and x2 are not the same size.

If a scalar value is passed in.

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)

See also

einsum

Einstein summation convention.

matmul

Matrix-matrix product.

vecdot

Vector-vector product.

vecmat

Vector-matrix product.

Aliases

  • numpy.matvec

Referenced by