Added the Strassen's Matrix Multiplication Algorithm#13482
Added the Strassen's Matrix Multiplication Algorithm#13482sourav-625 wants to merge 24 commits intoTheAlgorithms:masterfrom
Conversation
for more information, see https://pre-commit.ci
…625/Python into strassen_matrix_multiply
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
matrix/strassen_matrix_multiply.py
Outdated
| return unpad_matrix(c_pad, n_orig, n_orig) | ||
|
|
||
|
|
||
| def _strassen_recursive(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function _strassen_recursive
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
matrix/strassen_matrix_multiply.py
Outdated
| return unpad_matrix(c_pad, n_orig, n_orig) | ||
|
|
||
|
|
||
| def _strassen_recursive(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function _strassen_recursive
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| Matrix = list[list[int]] | ||
|
|
||
|
|
||
| def add_matrices(matrix_a: Matrix, matrix_b: Matrix) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function add_matrices
matrix/strassen_matrix_multiply.py
Outdated
| return [[matrix_a[i][j] + matrix_b[i][j] for j in range(size)] for i in range(size)] | ||
|
|
||
|
|
||
| def subtract_matrices(matrix_a: Matrix, matrix_b: Matrix) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function subtract_matrices
matrix/strassen_matrix_multiply.py
Outdated
| return [[matrix_a[i][j] - matrix_b[i][j] for j in range(size)] for i in range(size)] | ||
|
|
||
|
|
||
| def multiply_matrices_naive(matrix_a: Matrix, matrix_b: Matrix) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function multiply_matrices_naive
matrix/strassen_matrix_multiply.py
Outdated
| return result_matrix | ||
|
|
||
|
|
||
| def get_next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function get_next_power_of_two
Please provide descriptive name for the parameter: n
matrix/strassen_matrix_multiply.py
Outdated
| return top_left, top_right, bottom_left, bottom_right | ||
|
|
||
|
|
||
| def join_matrix_quadrants( |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function join_matrix_quadrants
matrix/strassen_matrix_multiply.py
Outdated
| return combined_matrix | ||
|
|
||
|
|
||
| def strassen_matrix_multiplication(matrix_a: Matrix, matrix_b: Matrix, threshold: int = 64) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function strassen_matrix_multiplication
matrix/strassen_matrix_multiply.py
Outdated
| return remove_matrix_padding(result_padded, original_size, original_size) | ||
|
|
||
|
|
||
| def _strassen_recursive_multiply(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function _strassen_recursive_multiply
matrix/strassen_matrix_multiply.py
Outdated
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| matrix_A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: matrix_A
matrix/strassen_matrix_multiply.py
Outdated
|
|
||
| if __name__ == "__main__": | ||
| matrix_A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | ||
| matrix_B = [[9, 8, 7], [6, 5, 4], [3, 2, 1]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: matrix_B
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
matrix/strassen_matrix_multiply.py
Outdated
| return unpad_matrix(c_pad, n_orig, n_orig) | ||
|
|
||
|
|
||
| def _strassen_recursive(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function _strassen_recursive
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
matrix/strassen_matrix_multiply.py
Outdated
| return unpad_matrix(c_pad, n_orig, n_orig) | ||
|
|
||
|
|
||
| def _strassen_recursive(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function _strassen_recursive
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
matrix/strassen_matrix_multiply.py
Outdated
| return unpad_matrix(c_pad, n_orig, n_orig) | ||
|
|
||
|
|
||
| def _strassen_recursive(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function _strassen_recursive
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
matrix/strassen_matrix_multiply.py
Outdated
| return unpad_matrix(c_pad, n_orig, n_orig) | ||
|
|
||
|
|
||
| def _strassen_recursive(matrix_a: Matrix, matrix_b: Matrix, threshold: int) -> Matrix: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file matrix/strassen_matrix_multiply.py, please provide doctest for the function _strassen_recursive
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| https://en.wikipedia.org/wiki/Strassen_algorithm | ||
| """ | ||
|
|
||
| Matrix = list[list[int]] |
There was a problem hiding this comment.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Matrix
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
matrix/strassen_matrix_multiply.py
Outdated
| return result | ||
|
|
||
|
|
||
| def next_power_of_two(n: int) -> int: |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: n
Describe your change:
Checklist: