Rate This Document
Findability
Accuracy
Completeness
Readability

vdot

Description

Return the dot product of two vectors.

The vdot(a, b) function handles complex numbers differently than dot(a, b). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product.

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.

Mandatory Input Parameters

Parameter

Type

Description

a

array_like

The first argument. If a is complex, the complex conjugate is taken before calculation of the dot product.

b

array_like

The second argument.

Optional Input Parameters

None

Return Value

Type

Description

ndarray

Returns the dot product of a and b. It can be int, float, or complex depending on the types of a and b.

Examples

>>> import numpy as np
>>> 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)
>>> 
>>> a = np.array([[1,4], [5,6]])
>>> b = np.array([[4,1], [2,2]])
>>> np.vdot(a, b)
30
>>> np.vdot(b, a)
30
>>>