Repository navigation
Reject singular RR and CC matrices in inverse - #4769
Open
diracdeltafunk wants to merge 1 commit into
Open
diracdeltafunk wants to merge 1 commit into
diracdeltafunk wants to merge 1 commit into
Conversation
Return the failure status from solve instead of reporting success when it cannot solve the identity system. This lets basicInverse raise the existing matrix-not-invertible error. Add two assertions to the existing inverse test. Fixes Macaulay2#4556.
d-torrance
self-requested a review
October 31, 2026 13:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
inversereturns a zero matrix for a singular matrix overRRorCCbecause the generic engine implementation ignores
solvereturning false.Return that result so the existing caller raises
matrix not invertible.For example,
inverse matrix{{1., 2.}, {2., 4.}}previously returned zero;it now raises an error.
Related issues and pull requests
Fixes #4556.
Testing
Built
M2-engine,M2-binary, andM2-coreon macOS arm64. Addedtwo assertions to the existing
tests/normal/inverse.m2for singularRRandCCmatrices. They fail with the old engine, and the fulltest file passes with the patched engine. Also checked that nonsingular
RRandCCmatrices still invert correctly.Release notes
inversenow raises an error for singular matrices overRRandCC.AI disclosure
Tools and models used: OpenAI Codex (GPT-6).
How AI was used, and on which parts: Codex investigated the bug, wrote
the fix and assertions, ran the checks, and drafted this description.
How I verified the result: I read the code.
License
Checklist
developmentbranch.