Skip to content
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

Added a .pinv() method to MultiVectors plus tests #367

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tBuLi
Copy link

@tBuLi tBuLi commented Oct 9, 2020

PR implementing #366.

I've added a method .pinv() to multivectors, which returns the pseudoinverse instead of the normal inverse. Identical to the matrix inverse method but when invoked on singular elements this does not throw an error but instead returns the original element, because well... it's singular.

@_cached_property
def pinv_func(self):
"""
Get a function that returns left-pseudoinverse using a computational
Copy link
Member

Choose a reason for hiding this comment

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

Is the left pseudo-inverse equal to the right pseudo-inverse (i.e., can you find a counterexample where it isn't?)

Copy link
Author

@tBuLi tBuLi Oct 9, 2020

Choose a reason for hiding this comment

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

Good question. I can't come up with a counter example. Something interesting and perhaps related I noticed is that if I replace the original np.linalg.solve with np.linalg.lstsq I get for the test example

Expected :0.5 + (3002399751580329.5^e2) - (0.5^e3) - (0.75^e13) - (3002399751580329.5^e23)
Actual   :0.5 - (0.5^e3)

I think it is save to say that this is undesired behavior. The pinv function clearly behaves much gentler. And in the numpy docs I see no mention of left and right actually, so perhaps we should leave that distinction altogether? Since it seems to return the input element anyway in case of singular behavior I don't see how that could be different left and right.

@eric-wieser
Copy link
Member

CI failures can be ignored. Thanks for the PR, I think I like the pinv name better than your previous suggestion anyway.

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

Successfully merging this pull request may close these issues.

3 participants