Created
January 17, 2017 08:46
-
-
Save mahdavipanah/cece1d861b8f88ed2cf4729bf8fdd8de to your computer and use it in GitHub Desktop.
Python matrix multiplication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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