Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/matrix-multiplication/oracle.py # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / matrix-multiplication / oracle.py` 15 lines ยท 784 bytes Raw Blame History 1 # Independent reference for "Matrix multiplication" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 def matmul(a, b): 4 # each entry as a dot product of a row of a with a column of b (zip(*b) gives the columns) 5 return [[sum(x * y for x, y in zip(row, col)) for col in zip(*b)] for row in a] 6 def show(m): 7 for row in m: 8 print("".join(f"{v:5}" for v in row)) 9 cases = [([[1, 2, 3], [4, 5, 6]], [[7, 8], [9, 10], [11, 12]]), 10 ([[3 * i - 10 for i in range(r * 3, r * 3 + 3)] for r in range(3)], 11 [[4 - (5 * i) % 7 for i in range(r * 3, r * 3 + 3)] for r in range(3)])] 12 for n, (a, b) in enumerate(cases): 13 if n: 14 print() 15 show(a); print("times"); show(b); print("equals"); show(matmul(a, b))