Modified matrix_mult to be a module
This commit is contained in:
parent
40f55dbf7d
commit
28e362f63f
@ -22,6 +22,9 @@ Example:
|
|||||||
... ]
|
... ]
|
||||||
>>> multiply(M, N)
|
>>> multiply(M, N)
|
||||||
[[7, 14], [3, 6]]
|
[[7, 14], [3, 6]]
|
||||||
|
|
||||||
|
NOTE: If you import the matrix_mult module into another project, call it with matrix_mult.multiply(M, N).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -37,17 +40,3 @@ def multiply(M: List[List], N: List[List]) -> List[List]:
|
|||||||
result[i][j] += M[i][k] * N[k][j]
|
result[i][j] += M[i][k] * N[k][j]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
M = [
|
|
||||||
[1, 2, 4],
|
|
||||||
[0, 1, 2]
|
|
||||||
]
|
|
||||||
|
|
||||||
N = [
|
|
||||||
[1, 2],
|
|
||||||
[3, 4],
|
|
||||||
[0, 1]
|
|
||||||
]
|
|
||||||
|
|
||||||
print(multiply(M, N))
|
|
||||||
Loading…
Reference in New Issue
Block a user