Skip to content

Instantly share code, notes, and snippets.

View hao-gu's full-sized avatar

hao gu hao-gu

  • UCLA
  • Cupertino, CA
View GitHub Profile
def matmul(matrix_a, matrix_b):
rows_a = len(matrix_a)
cols_a = len(matrix_a[0])
rows_b = len(matrix_b)
cols_b = len(matrix_b[0])
result_matrix = [[0 for _ in range(cols_b)] for _ in range(rows_a)]
for i in range(rows_a):
for j in range(cols_b):
for k in range(cols_a):
result_matrix[i][j] += matrix_a[i][k] * matrix_b[k][j]