Created
August 26, 2019 05:16
-
-
Save badgateway666/b520203288d8247bb62469b817e27167 to your computer and use it in GitHub Desktop.
Matrix multiplication v1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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