-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
hey! I have added determinant_of_nxn_matrix.py #4399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
added determinant_of_nxn_matrix.py file which is used to find determinant of nxn matrix
…of_nxn_matrix Create determinant_of_nxn_matrix.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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/determinant_of_nxn_matrix.py
Outdated
from copy import deepcopy | ||
|
||
|
||
def determinant_of_nxn_matrix(a: list[list[float]]) -> float: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptive name for the parameter: a
descriptive name of list[list[]] as matrix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. Here is my review. Be sure to add comments describing the steps in the process. These don't have to be extensive, but will help the reader better understand the algorithm.
If you disagree with any of my comments, feel free to address them by commenting.
""">>> determinant_of_nxn_matrix([[10, 5], [3, 2.5]]) | ||
10.0 | ||
>>> determinant_of_nxn_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 10]]) | ||
-3.0 | ||
>>> determinant_of_nxn_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 4]]) | ||
15.0 | ||
>>> determinant_of_nxn_matrix([[1, 2, 3, 7], [4, 5, 6, 6], | ||
[7, 8, 1, 5], [1, 2, 3, 4]]) | ||
-72.0 | ||
>>> determinant_of_nxn_matrix([[1, 2, 3, 7, 13], [4, 5, 6, 6, 90], | ||
[7, 8, 1, 5, 76], | ||
[1, 2, 3, 4, 12], [9, 6, 3, 7, 4]]) | ||
19848.0 | ||
>>> determinant_of_nxn_matrix([[1, 2, 3, 7, 13, 23], | ||
[4, 44, 6, 6, 90, 12], | ||
[7, 8, 1, 5, 6, 98], [1, 2, 3, 4, 12, 4], | ||
[9, 6, 3, 7, 4, 9], [2, 47, 8, 91, 36, 9]]) | ||
-20981553.999999993""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readable docstring formatting:
""">>> determinant_of_nxn_matrix([[10, 5], [3, 2.5]]) | |
10.0 | |
>>> determinant_of_nxn_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 10]]) | |
-3.0 | |
>>> determinant_of_nxn_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 4]]) | |
15.0 | |
>>> determinant_of_nxn_matrix([[1, 2, 3, 7], [4, 5, 6, 6], | |
[7, 8, 1, 5], [1, 2, 3, 4]]) | |
-72.0 | |
>>> determinant_of_nxn_matrix([[1, 2, 3, 7, 13], [4, 5, 6, 6, 90], | |
[7, 8, 1, 5, 76], | |
[1, 2, 3, 4, 12], [9, 6, 3, 7, 4]]) | |
19848.0 | |
>>> determinant_of_nxn_matrix([[1, 2, 3, 7, 13, 23], | |
[4, 44, 6, 6, 90, 12], | |
[7, 8, 1, 5, 6, 98], [1, 2, 3, 4, 12, 4], | |
[9, 6, 3, 7, 4, 9], [2, 47, 8, 91, 36, 9]]) | |
-20981553.999999993""" | |
""" | |
>>> determinant_of_nxn_matrix([[10, 5], [3, 2.5]]) | |
10.0 | |
>>> determinant_of_nxn_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 10]]) | |
-3.0 | |
>>> determinant_of_nxn_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 4]]) | |
15.0 | |
>>> determinant_of_nxn_matrix([ | |
... [1, 2, 3, 7], [4, 5, 6, 6], [7, 8, 1, 5], [1, 2, 3, 4] | |
... ]) | |
-72.0 | |
>>> determinant_of_nxn_matrix([ | |
... [1, 2, 3, 7, 13], | |
... [4, 5, 6, 6, 90], | |
... [7, 8, 1, 5, 76], | |
... [1, 2, 3, 4, 12], | |
... [9, 6, 3, 7, 4] | |
... ]) | |
19848.0 | |
>>> determinant_of_nxn_matrix([ | |
... [1, 2, 3, 7, 13, 23], | |
... [4, 44, 6, 6, 90, 12], | |
... [7, 8, 1, 5, 6, 98], | |
... [1, 2, 3, 4, 12, 4], | |
... [9, 6, 3, 7, 4, 9], | |
... [2, 47, 8, 91, 36, 9] | |
... ]) | |
-20981553.999999993 | |
""" |
n = 0 | ||
m = 1 | ||
c1 = 1 | ||
c2 = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more descriptive names for these variables and add comments describing their purpose.
[9, 6, 3, 7, 4, 9], [2, 47, 8, 91, 36, 9]]) | ||
-20981553.999999993""" | ||
|
||
size = int(len(matrix)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for the int
. The built-in len
function returns an integer.
size = int(len(matrix)) | |
size = len(matrix) |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions! |
this algorithm find the determinant of nxn matrix using Row Echelon Method:
Checklist:
Fixes: #{$ISSUE_NO}
.