Skip to content

Instantly share code, notes, and snippets.

@itamar121
Forked from mahdavipanah/matrix_multiply.py
Created November 9, 2020 00:22
Show Gist options
  • Save itamar121/0a2f28b4f3aef343e0ef93e578545a31 to your computer and use it in GitHub Desktop.
Save itamar121/0a2f28b4f3aef343e0ef93e578545a31 to your computer and use it in GitHub Desktop.
Python matrix multiplication
def matrix_multiply(a, b):
c = [[] for _ in range(len(a))]
for i in range(len(a)):
for j in range(len(a)):
sum = 0
for k in range(len(a)):
sum += a[i][k] * b[k][j]
c[i].append(sum)
return c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment