Matrix multiplication: Difference between revisions

m
(→‎{{header|Python}}: add list comp oneliner)
Line 2,340:
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
Anonymous user