mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Fix type error in strassen_matrix_multiplication.py
(#8784)
* Fix type error in strassen_matrix_multiplication.py * updating DIRECTORY.md --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
4b79d771cd
commit
c93659d7ce
|
@ -294,6 +294,7 @@
|
|||
* [Mergesort](divide_and_conquer/mergesort.py)
|
||||
* [Peak](divide_and_conquer/peak.py)
|
||||
* [Power](divide_and_conquer/power.py)
|
||||
* [Strassen Matrix Multiplication](divide_and_conquer/strassen_matrix_multiplication.py)
|
||||
|
||||
## Dynamic Programming
|
||||
* [Abbreviation](dynamic_programming/abbreviation.py)
|
||||
|
|
|
@ -112,17 +112,19 @@ def strassen(matrix1: list, matrix2: list) -> list:
|
|||
[[139, 163], [121, 134], [100, 121]]
|
||||
"""
|
||||
if matrix_dimensions(matrix1)[1] != matrix_dimensions(matrix2)[0]:
|
||||
raise Exception(
|
||||
"Unable to multiply these matrices, please check the dimensions. \n"
|
||||
f"Matrix A:{matrix1} \nMatrix B:{matrix2}"
|
||||
msg = (
|
||||
"Unable to multiply these matrices, please check the dimensions.\n"
|
||||
f"Matrix A: {matrix1}\n"
|
||||
f"Matrix B: {matrix2}"
|
||||
)
|
||||
raise Exception(msg)
|
||||
dimension1 = matrix_dimensions(matrix1)
|
||||
dimension2 = matrix_dimensions(matrix2)
|
||||
|
||||
if dimension1[0] == dimension1[1] and dimension2[0] == dimension2[1]:
|
||||
return [matrix1, matrix2]
|
||||
|
||||
maximum = max(dimension1, dimension2)
|
||||
maximum = max(*dimension1, *dimension2)
|
||||
maxim = int(math.pow(2, math.ceil(math.log2(maximum))))
|
||||
new_matrix1 = matrix1
|
||||
new_matrix2 = matrix2
|
Loading…
Reference in New Issue
Block a user