vdot

vdot(a, b)

Return the dot product of two vectors. Note that vdot handles multidimensional arrays differently than dot: it does not perform a matrix product, but flattens input arguments to 1-D vectors first. Consequently, it should only be used for vectors.

Parameters:
a : ndarray

First argument to the dot product.

b : ndarray

Second argument to the dot product.

Returns:
output : ndarray

Dot product of a and b.

See also

dot
Return the dot product without using the complex conjugate of the first argument.

Examples

Note that higher-dimensional arrays are flattened!

>>> a = np.array([[1, 4], [5, 6]])
>>> b = np.array([[4, 1], [2, 2]])
>>> np.vdot(a, b)
array(30.)
>>> np.vdot(b, a)
array(30.)
>>> 1*4 + 4*1 + 5*2 + 6*2
30