Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

sudip777sharma
Copy link

this algorithm find the determinant of nxn matrix using Row Echelon Method:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

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
@ghost ghost added awaiting reviews This PR is ready to be reviewed require descriptive names This PR needs descriptive function and/or variable names labels May 4, 2021
Copy link

@ghost ghost left a 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.

from copy import deepcopy


def determinant_of_nxn_matrix(a: list[list[float]]) -> float:
Copy link

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
@ghost ghost removed the require descriptive names This PR needs descriptive function and/or variable names label May 4, 2021
Copy link
Member

@mrmaxguns mrmaxguns left a 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.

Comment on lines +11 to +28
""">>> 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"""
Copy link
Member

@mrmaxguns mrmaxguns May 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readable docstring formatting:

Suggested change
""">>> 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
"""

Comment on lines +32 to +35
n = 0
m = 1
c1 = 1
c2 = 0
Copy link
Member

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))
Copy link
Member

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.

Suggested change
size = int(len(matrix))
size = len(matrix)

@ghost ghost added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels May 30, 2021
@stale
Copy link

stale bot commented Jun 30, 2021

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.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Jun 30, 2021
@stale
Copy link

stale bot commented Jul 8, 2021

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!

@stale stale bot closed this Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes A maintainer has requested changes to this PR stale Used to mark an issue or pull request stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants