VOOZH about

URL: https://www.geeksforgeeks.org/python/numpy-vdot-python/

⇱ numpy.vdot() in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

numpy.vdot() in Python

Last Updated : 10 Dec, 2025

numpy.vdot() returns the dot product of two vectors. If the first vector contains complex numbers, vdot() automatically takes its complex conjugate before performing the multiplication. For multi-dimensional arrays, it first flattens them and then computes the dot product.

Example: This example shows how numpy.vdot() works on complex numbers by conjugating the first input.


Output
(23-2j)

Explanation:

  • np.vdot(a, b) -> uses conjugate(a) = 2 - 3j.
  • Computes: (2 - 3j) * (4 + 5j) -> 23 - 2j.

Syntax

numpy.vdot(a, b)

Parameters:

  • a (array_like): First input vector. If complex, its conjugate is used.
  • b (array_like): Second input vector.

Examples

Example 1: This example shows how vdot() conjugates the first complex value before multiplication.


Output
(11-2j)

Explanation:

  • Conjugate of a -> 1 - 2j.
  • Computation -> (1 - 2j) * (3 + 4j) = 11 + 2j.

Example 2: Here both arrays are 2×2 matrice, vdot() flattens them and performs element-wise multiplication.


Output
55

Explanation:

  • Flattened arrays -> a = [1,4,5,6], b = [2,4,5,2].
  • Dot product -> 1*2 + 4*4 + 5*5 + 6*2 = 55.

Example 3: This example shows vdot() working like a normal dot product when inputs are real numbers.


Output
17

Explanation: Computes -> 3*2 + 7*1 + 1*4 = 17.

Comment
Article Tags:
Article Tags: