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
incorrect inverse of sparse matrix over inexact rings #28402
Comments
Commit: |
comment:1
Okay, so I figured out the problem. Basically it comes from the inexactness of the arithmetic. There are a lot of non-zero entries in the part of the augmented matrix that are normally 0 but are not when working over inexact fields. So I just moved that special construction to only be for exact fields as the resulting matrix is much more likely to be dense anyways for inexact fields. New commits:
|
Author: Travis Scrimshaw |
comment:2
Can't reproduce:
No relevant packages installed:
Do you use any relevant packages ? |
comment:3
Maybe it is computer dependent? I am able to reproduce it on
|
comment:4
Replying to @tscrim:
Debian testing running on core i7 + 16 GB RAM here. On another machine, slightly smalle (Debian testing, core i5 + 8 GB RAM):
EDIT :
I'll upgrade to beta8 and report results. [ Bandwidth savings : ... ] HTH, |
comment:5
Replying to @EmmanuelCharpentier:
Same results :
I'm using a Python 3-based Sage 8.9.beta8, but I can't see how it would make a difference... |
comment:6
I would argue this change still makes sense for the reasons I gave in comment:1. It is assuming that after doing the rref we obtain |
comment:7
Thanks for the fix. I would suggest to:
|
Reviewer: Thierry Monteil |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:9
Good ideas. Done. |
comment:10
Replying to @EmmanuelCharpentier:
I also cannot replicate the issue with Python 3, whereas I can using Python 2, on those same machines. Any idea what could be causing this? |
comment:11
Actually, having had a look at the implementation, the reason why this seemingly works with Python 3 is that iterating over dicts is done in an ordered fashion, whereas it is done in arbitrary order with Python 2. Thus, the extraneous non-zero entries in the left half of the augmented matrix are consistently overwritten by entries on the right if they exist. All in all, I agree this is the correct solution. |
comment:12
Thank you for investigating it. That would also explain why it works for some people in Python 2 as well. Patchbot is (morally) green as well. |
comment:13
Also, I think this should be a blocker because it is a fundamental computation that can silently returns a wrong answer. |
comment:15
Thank you. |
Changed branch from public/linear_algebra/fix_sparse_inverse_inexact_fields-28402 to |
As reported on this ask question, we have:
Note that reverting #24122, by removing the call to
build_inverse_from_augmented_sparse
in the__invert__
method ofsage/matrix/matrix0.pyx
(line 5410), leads to a correct answer.CC: @tscrim @videlec
Component: linear algebra
Author: Travis Scrimshaw
Branch/Commit:
df1cbce
Reviewer: Thierry Monteil
Issue created by migration from https://trac.sagemath.org/ticket/28402
The text was updated successfully, but these errors were encountered: