SHARE
TWEET

Untitled

a guest May 16th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import random
  3. import pprint
  4. import time
  5.  
  6. pp = pprint.PrettyPrinter(indent=2)
  7. MATRIX_SIZE = 10000
  8. MAX_RANGE = 10000
  9.  
  10. A = MAX_RANGE * np.random.random((MATRIX_SIZE, MATRIX_SIZE)) - MAX_RANGE/2
  11. b = MAX_RANGE * np.random.random((MATRIX_SIZE)) - MAX_RANGE/2
  12.  
  13. def multiplyMatrixWithVector(matrix, vector):
  14.   result = []
  15.   size = len(vector)
  16.   for r in range(size):
  17.     sum = 0
  18.     for c in range(size):
  19.       sum += matrix[r][c] * vector[c]
  20.     result.append(sum)
  21.   return result
  22.  
  23. start = time.time()
  24. c1 = multiplyMatrixWithVector(A, b)
  25. end = time.time()
  26.  
  27. print('============ TIME ===========')
  28. print(end-start)
  29. print('============ TIME ===========')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top