Skip to content

Commit a337a94

Browse files
committed
feat: Strassen's matrix multiplication algorithm added
1 parent 8aea982 commit a337a94

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

matrix/strassen_matrix_multiply.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ def strassen(matrix_a: Matrix, matrix_b: Matrix, threshold: int = 64) -> Matrix:
158158

159159

160160
def _strassen_recursive(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix:
161+
"""
162+
Recursive helper for Strassen's algorithm.
163+
164+
>>> _strassen_recursive([[1, 2], [3, 4]], [[5, 6], [7, 8]], 1)
165+
[[19, 22], [43, 50]]
166+
"""
161167
n = len(matrix_a)
162168
if n <= threshold:
163169
return naive_multiplication(matrix_a, matrix_b)

0 commit comments

Comments
 (0)