Skip to content

Added determinate function #1429

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

Merged
merged 5 commits into from
Oct 24, 2019
Merged

Added determinate function #1429

merged 5 commits into from
Oct 24, 2019

Conversation

codecalec
Copy link
Contributor

Hi.
This is my first pull request so just let me know if there is anything else I should do. I thought the linear algebra class was missing a pretty important aspect of real valued matrices so thought it should be included.

It uses Laplace expansion to find the determinate recursively. It a pretty slow algorithm but it does the trick.

"""
A = Matrix([[1, 1, 4, 5], [3, 3, 3, 2], [5, 1, 9, 0], [9, 7, 7, 9]], 4, 4)
self.assertEqual(-376, A.determinate())

Copy link
Member

@cclauss cclauss Oct 24, 2019

Choose a reason for hiding this comment

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

Please add the following function to the bottom of this file just above line 160.

def force_test() -> None:
    """
    This will ensure that pytest runs the unit tests above.
    >>> unittest.main()
    """
    pass

Copy link
Member

Choose a reason for hiding this comment

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

We can see that our tests are not being run:
https://travis-ci.com/TheAlgorithms/Python/builds/133339192#L386

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Copy link
Member

@cclauss cclauss 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 this! A really nice addition. I commented out the test and we can fix it in #1124.

If Travis passes on my change, I will land this one.

@cclauss cclauss merged commit 0748313 into TheAlgorithms:master Oct 24, 2019
@codecalec codecalec deleted the pr/det branch October 24, 2019 09:09
@codecalec
Copy link
Contributor Author

Awesome. Sorry for the hiccups

@cclauss
Copy link
Member

cclauss commented Oct 24, 2019

No problems.

@cclauss
Copy link
Member

cclauss commented Oct 24, 2019

Please give some thought to #1124 (comment)

stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Added determinate function

* Changed determinate function name

* Changed instance of .det() to .determinate()

* Added force_test() function

* Update tests.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants