Skip to content

Commit b377882

Browse files
saahil-mahatotianyizheng02
authored andcommitted
Mention square matrices in strassen docs and make it more clear (TheAlgorithms#9839)
* refactor: fix strassen matrix multiplication docs * refactor: make docs more clear
1 parent 5311488 commit b377882

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: divide_and_conquer/strassen_matrix_multiplication.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def print_matrix(matrix: list) -> None:
7474
def actual_strassen(matrix_a: list, matrix_b: list) -> list:
7575
"""
7676
Recursive function to calculate the product of two matrices, using the Strassen
77-
Algorithm. It only supports even length matrices.
77+
Algorithm. It only supports square matrices of any size that is a power of 2.
7878
"""
7979
if matrix_dimensions(matrix_a) == (2, 2):
8080
return default_matrix_multiplication(matrix_a, matrix_b)
@@ -129,8 +129,8 @@ def strassen(matrix1: list, matrix2: list) -> list:
129129
new_matrix1 = matrix1
130130
new_matrix2 = matrix2
131131

132-
# Adding zeros to the matrices so that the arrays dimensions are the same and also
133-
# power of 2
132+
# Adding zeros to the matrices to convert them both into square matrices of equal
133+
# dimensions that are a power of 2
134134
for i in range(maxim):
135135
if i < dimension1[0]:
136136
for _ in range(dimension1[1], maxim):

0 commit comments

Comments
 (0)