In [32]:
import numpy as np
import time
In [33]:
x1 = [9, 2, 5, 0, 0, 7, 5, 0, 0, 0, 9, 2, 5, 0, 0]
x2 = [9, 2, 2, 9, 0, 9, 2, 5, 0, 0, 9, 2, 5, 0, 0]
### VECTORIZED DOT PRODUCT OF VECTORS ###
tic = time.process_time()
dot = np.dot(x1,x2)
toc = time.process_time()
print ("Dot Vectors = " + str(dot) + "\nComputation time = " + str(1000*(toc - tic)) + "ms")
In [34]:
### VECTORIZED OUTER PRODUCT ###
tic = time.process_time()
outer = np.outer(x1,x2)
toc = time.process_time()
print ("###############> Outer Product <###############>\t\n"
+str(outer)+ "\n\nComputation time = " + str(1000*(toc - tic)) + "ms")
In [35]:
### VECTORIZED ELEMENTWISE MULTIPLICATION ###
tic = time.process_time()
mul = np.multiply(x1,x2)
toc = time.process_time()
print ("Elementwise Multiplication = " + str(mul) + "\nComputation time = "+str(1000*(toc - tic))+"ms")
In [36]:
### VECTORIZED GENERAL DOT PRODUCT ###
tic = time.process_time()
dot = np.dot(x1,x2)
toc = time.process_time()
print ("gdot = " + str(dot) + "\n ----- Computation time = " + str(1000*(toc - tic)) + "ms")
In [ ]: