Skip to content

Instantly share code, notes, and snippets.

@ericzakariasson
Created February 28, 2021 20:48
Show Gist options
  • Save ericzakariasson/753dec2fe8e7438b2fb643914d8cec8d to your computer and use it in GitHub Desktop.
Save ericzakariasson/753dec2fe8e7438b2fb643914d8cec8d to your computer and use it in GitHub Desktop.
def matrix_multiplication(a, b):
if len(b) == 0 or len(a) == 0:
return []
c = []
for i in range(len(a)):
c.append([])
for j in range(len(b[0])):
c[-1].append(0.0)
for i in range(len(a)):
for j in range(len(b[0])):
total = 0
for k in range(len(a[0])):
total += a[i][k] * b[k][j]
c[i][j] = total
return c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment