Skip to content

Reject singular RR and CC matrices in inverse - #4769

Open
diracdeltafunk wants to merge 1 commit into
Macaulay2:developmentfrom
aimathconference:codex/fix-inexact-singular-inverse
Open

diracdeltafunk wants to merge 1 commit into
Macaulay2:developmentfrom
aimathconference:codex/fix-inexact-singular-inverse

Conversation

@diracdeltafunk

Copy link
Copy Markdown
Contributor

Description

inverse returns a zero matrix for a singular matrix over RR or CC
because the generic engine implementation ignores solve returning 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, and M2-core on macOS arm64. Added
two assertions to the existing tests/normal/inverse.m2 for singular
RR and CC matrices. They fail with the old engine, and the full
test file passes with the patched engine. Also checked that nonsingular
RR and CC matrices still invert correctly.

Release notes

inverse now raises an error for singular matrices over RR and CC.

AI disclosure

  • 0 — No AI tools were used or consulted.
  • 1 — AI was used only for lookups, explanations, or advice; it wrote no code or text in this pull request.
  • 2 — AI made small edits, which I reviewed.
  • 3 — AI drafted substantial parts, which I reviewed.
  • 4 — AI produced most or all of the content, which I reviewed thoroughly.
  • 5 — AI produced the content with minimal human review.

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

  • My changes use the existing license of the affected files or package.
  • I release my new material under the GNU GPL, version 2 or later.
  • Other (public domain, another license, or not applicable); details below.

Checklist

  • This pull request targets the development branch.
  • I have reviewed my own changes.
  • Documentation and tests are updated as needed.

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
d-torrance self-requested a review October 31, 2026 13:15
@d-torrance d-torrance added Engine Macaulay2/e AI-generated This PR contains AI-generated code or this issue was written by AI labels Oct 31, 2026
@d-torrance
d-torrance requested a review from ddale27 October 31, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-generated This PR contains AI-generated code or this issue was written by AI Engine Macaulay2/e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inverse of a singular matrix over RR or CC returns the zero matrix instead of erroring

2 participants