Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Matrix multiplication algorithm by spel3o
- def show_tell(a,b):
- display(matrix_multiply(a,b))
- def display(matrix):
- for i in range(len(matrix)):
- print matrix[i]
- def maketrix(m,n):
- result = [[0 for row in range(n)] for col in range(m)]
- return result
- def matrix_multiply(a,b):
- if len(a[0]) != len(b):
- print 'Matrix multiplication not possible'
- else:
- n = len(a)
- m = len(a[0])
- p = len(b[0])
- result = maketrix(n,p)
- for pony in range(p):
- for murk in range(m):
- for nope in range(n):
- result[nope][pony] += a[nope][murk]*b[murk][pony]
- return result
Add Comment
Please, Sign In to add comment