numpy.vdot#
- numpy.vdot(a,b,/)#
Return the dot product of two vectors.
The
vdotfunction handles complex numbers differently thandot:if the first argument is complex, it is replaced by its complex conjugatein the dot product calculation.vdotalso handles multidimensionalarrays differently thandot: it does not perform a matrix product, butflattens the arguments to 1-D arrays before taking a vector dot product.Consequently, when the arguments are 2-D arrays of the same shape, thisfunction effectively returns theirFrobenius inner product(also known as thetrace inner product or thestandard inner producton a vector space of matrices).
- Parameters:
- aarray_like
Ifa is complex the complex conjugate is taken before calculationof the dot product.
- barray_like
Second argument to the dot product.
- Returns:
- outputndarray
Dot product ofa andb. Can be an int, float, orcomplex depending on the types ofa andb.
See also
dotReturn the dot product without using the complex conjugate of the first argument.
Examples
>>>importnumpyasnp>>>a=np.array([1+2j,3+4j])>>>b=np.array([5+6j,7+8j])>>>np.vdot(a,b)(70-8j)>>>np.vdot(b,a)(70+8j)
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)30>>>np.vdot(b,a)30>>>1*4+4*1+5*2+6*230