27 lines
609 B
Python
27 lines
609 B
Python
|
def mkslot(m, i, j):
|
||
|
ij = j + i * 4
|
||
|
return f"{m}[{ij}]"
|
||
|
# return m + "xyzw"[i] + str(j + 1)
|
||
|
|
||
|
def mm(leftcalled = "l", rightcalled = "r"):
|
||
|
stmts = []
|
||
|
|
||
|
for i in range(4):
|
||
|
for j in range(4):
|
||
|
res = mkslot("m", i, j)
|
||
|
terms = []
|
||
|
|
||
|
for k in range(4):
|
||
|
left = mkslot(leftcalled, i, k)
|
||
|
right = mkslot(rightcalled, k, j)
|
||
|
|
||
|
term = f"{left} * {right}"
|
||
|
terms.append(term)
|
||
|
|
||
|
stmt = f"{res} = {' + '.join(terms)};"
|
||
|
stmts.append(stmt)
|
||
|
|
||
|
return "\n".join(stmts)
|
||
|
|
||
|
print(mm())
|