Advertisement
Tyler_Elric

matrices.py

Feb 23rd, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. def multiply_matrices(a,b):
  2.     wa, ha, wb, hb = len(a[0]), len(a),len(b[0]), len(b)
  3.     assert wa == hb
  4.     for row in range(ha):
  5.         yield [sum(map(lambda x,y:x*y[col], a[row], b)) for col in range(wb)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement