Open In App

NumPy | Vector Multiplication

Vector multiplication is of three types:

w =  [20  5]



Dot Product multiplication:

Code: Python code to explain Dot Product Multiplication




import numpy as np
import math
  
v = np.array([2, 1])
s = np.array([3, -2])
d = np.dot(v, s)
print(d)

Here, dot product can also be received using the ‘@’ operator.

d = v@s

Output :

4

Cross Product:

Code: Python code explaining Cross Product




import numpy as np
import math
  
v = np.array([4, 9, 12])
s = np.array([21, 32, 44])
r = np.cross(v, s)
print(r)

Output:

[ 12  76 -61]

Article Tags :