We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dda49c5 commit cde9409Copy full SHA for cde9409
divide_and_conquer/strassen_matrix_multiplication.py
@@ -119,12 +119,15 @@ def strassen(matrix1: list, matrix2: list) -> list:
119
>>> strassen([[2,1,3],[3,4,6],[1,4,2],[7,6,7]], [[4,2,3,4],[2,1,1,1],[8,6,4,2]])
120
[[34, 23, 19, 15], [68, 46, 37, 28], [28, 18, 15, 12], [96, 62, 55, 48]]
121
122
- >>> strassen([[3,7,5,6,9],[1,5,3,7,8],[1,4,4,5,7]], [[2,4],[5,2],[1,7],[5,5],[7,8]])
123
- [[139, 163], [121, 134], [100, 121]]
+ >>> strassen(
+... [[3,7,5,6,9],[1,5,3,7,8],[1,4,4,5,7]],
124
+... [[2,4],[5,2],[1,7],[5,5],[7,8]]
125
+... )
126
+
127
128
Complexity Notes:
129
- Classical matrix multiplication: O(n^3).
- - Strassen’s algorithm: O(n^(log2(7))) ≈ O(n^2.81).
130
+ - Strassen's algorithm: O(n^(log2(7))) ≈ O(n^2.81).
131
- Strassen reduces the number of multiplications from 8 to 7 per recursion,
132
trading them for additional additions/subtractions.
133
"""
0 commit comments