Skip to content

Instantly share code, notes, and snippets.

@b1naryth1ef
Created August 18, 2011 03:21
Show Gist options
  • Save b1naryth1ef/1153220 to your computer and use it in GitHub Desktop.
Save b1naryth1ef/1153220 to your computer and use it in GitHub Desktop.
MultiMatrix
def zero(m,n):
return [[0 for row in range(n)] for col in range(m)]
def mult(matrix1,matrix2):
if len(matrix1[0]) != len(matrix2):
print 'Cant do that on that shiznip!'
else:
new_matrix = zero(len(matrix1),len(matrix2[0]))
for i in range(len(matrix1)):
for j in range(len(matrix2[0])):
for k in range(len(matrix2)):
new_matrix[i][j] += matrix1[i][k]*matrix2[k][j]
return new_matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment