Change language

numpy.vdot () in Python

|

Parameters —

  1. vector_a: [array_like], if a is complex, its complex conjugate is used to calculate the point product.
  2. vector_b: [array_like], if b is complex, its complex conjugate is used to compute the dot product.

Return — point Product of vectors a and b.

Code 1:

# Python program illustrating
# numpy.vdot () method

 

import numpy as geek

  
# 1D array

vector_a =   2 + 3j

vector_b = 4 + 5j

 

product = geek.vdot (vector_a, vector_b)

print ( "Dot Product :" , product)

Output:

 Dot Product: (23-2j) 

How does Code1 work?
vector_a = 2 + 3j
vector_b = 4 + 5j

According to the method, take the conjugation of vector_a, i.e. 2 — 3j

now product point = 2 (4 — 5j) + 3j (4 — 5j)
= 8 — 10j + 12j + 15
= 23 — 2j

Code 2:

Output:

 Dot Product: 55 Dot Product: 55 

Links:
https://docs .scipy.org / doc / numpy-dev / reference / generated / numpy.vdot.html # numpy.vdot

,
This article is courtesy of Mohit Gupta_OMG

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method

# Python program illustrating
# numpy.vdot () method

 

import numpy as geek

  
# 1D array

vector_a = geek.array ([[ 1 , 4 ], [ 5 , 6 ]])

vector_b = geek.array ([[ 2 4 ], [ 5 , 2 ]])

  

product = geek.vdot (vector_a, vector_b)

print ( "Dot Product :" , product)

 

product = geek.vdot (vector_b, vector_a)

print ( "Dot Product :" , product)

 
"" "
How Code 2 works:
array is aligned

 
1 * 2 + 4 * 4 + 5 * 5 + 6 * 2 = 55
"" "