nalgebra icon indicating copy to clipboard operation
nalgebra copied to clipboard

Update inverse.rs - improved code doc try_inverse_mut

Open tencek opened this issue 1 year ago • 2 comments

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

tencek avatar May 23 '24 07:05 tencek

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?

Andlon avatar Jun 12 '24 09:06 Andlon

@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.

tencek avatar Jun 18 '24 08:06 tencek