Skip to content

Instantly share code, notes, and snippets.

@thblckjkr
Created May 20, 2019 23:03
Show Gist options
  • Save thblckjkr/db2840691c348590bf2ff6397070713e to your computer and use it in GitHub Desktop.
Save thblckjkr/db2840691c348590bf2ff6397070713e to your computer and use it in GitHub Desktop.
import datetime
class matrix:
n = 3
A = []
B = []
C = []
def __init__(self, n):
self.n = n
self.fill()
def fill(self):
self.A = [[1 for x in range(self.n)] for y in range(self.n)]
self.B = [[1 for x in range(self.n)] for y in range(self.n)]
self.C = [[0 for x in range(self.n)] for y in range(self.n)]
def multiply(self):
for i in range(0, self.n):
for j in range(0, self.n):
for k in range(0, self.n):
self.C[i][k] += self.A[i][j] * self.B[j][k]
for x in range(0, 201, 10):
a = matrix(x)
inicio = datetime.datetime.now()
a.multiply()
final = datetime.datetime.now()
tiempo = final - inicio
print(str(x) + "," + str(tiempo.microseconds) + "ms" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment