Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.