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

Update inverse.rs - improved code doc try_inverse_mut #1399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tencek
Copy link

@tencek tencek commented May 23, 2024

The "and leaves self untouched" part of the code doc was wrong. Self may be modified before early false return.
See https://github.com/dimforge/nalgebra/blob/dev/src/linalg/lu.rs#L64

The "and leaves `self` untouched" part of the code doc was wrong. Self may be modified before early false return.
@Andlon
Copy link
Collaborator

Andlon commented Jun 12, 2024

I believe this was fixed in #1384 for the 4x4 case. I think it should work for the other cases. Can you confirm whether this fixes the issue for you @tencek?

@tencek
Copy link
Author

tencek commented Jun 18, 2024

@Andlon - thank you for looking into this one and I apologize for my slow response.
The 4x4 case seems to be fine. The case that caused my troubles was 6x6. Please have a look at this unit test that is failing on the dev branch:
test_inversion_failure_leaves_matrix6_unchanged

Fun fact: the unit test, including the values, was completely generated by the CoPilot. I just found the right place where to add the new test and was about to copy and paste the values I used in my software to replicate the issue. But the CoPilot was quicker and the values generated also replicated the bug.

In the try_invert_to function, the out matrix is filled with identity first, and then later it returns false.

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