Skip to content

Instantly share code, notes, and snippets.

@badgateway666
Created August 26, 2019 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badgateway666/b520203288d8247bb62469b817e27167 to your computer and use it in GitHub Desktop.
Save badgateway666/b520203288d8247bb62469b817e27167 to your computer and use it in GitHub Desktop.
Matrix multiplication v1
def matrix_multiply(m_1, m_2):
assert len(m_1[0]) == len(m_2)
r = list(map(lambda m: sum([x * y for x, y in zip(*m)]), [(x, y) for x in m_1 for y in zip(*m_2)]))
return [r[x:x+len(m_2[0])] for x in range(0, len(m_1)*len(m_2[0]), len(m_2[0]))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment