Matrix multiplication: Difference between revisions
Content added Content deleted
m (explanatory note added) |
(→{{header|Python}}: add list comp oneliner) |
||
Line 2,338: | Line 2,338: | ||
m1)</lang> |
m1)</lang> |
||
Using list comprehensions, multiplying matrices represented as lists of lists. (Input is not validated): |
|||
<lang python>def mm(A, B): |
|||
return [[sum([x * B[i][col] for i,x in enumerate(row)]) for col in range(len(B[0]))] for row in A]</lang> |
|||
Another one, use numpy the most popular array package for python |
Another one, use numpy the most popular array package for python |