This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / vecmat

ufunc

numpy:vecmat

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

Summary

Vector-matrix dot product of two arrays.

Extended Summary

Given a vector (or stack of vector) in x1 and a matrix (or stack of matrices) in x2, the vector-matrix product is defined as:

where the sum is over the last dimension of x1 and the one-but-last dimensions in x2 (unless axes is specified) and where denotes the complex conjugate if is complex and the identity otherwise. (For a non-conjugated vector-matrix product, use np.matvec(x2.mT, x1).)

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 vector-matrix product of the inputs.

Raises

: ValueError

If the last dimensions of x1 and the one-but-last dimension of x2 are not the same size.

If a scalar value is passed in.

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)

See also

einsum

Einstein summation convention.

matmul

Matrix-matrix product.

matvec

Matrix-vector product.

vecdot

Vector-vector product.

Aliases

  • numpy.vecmat

Referenced by