Conversation
The parametrizations in shape position are obtained by solving Hankel systems with a Gohberg-Semencul type formula, which requires the constant coefficient of the first generator Z1 to be nonzero. For a random sequence this fails with probability about 1/p, when a sub-block of size dim - 1 of the Hankel matrix is singular. The code handling this case borders the Hankel matrix into one of size dim + 1, for which the formula applies, but it silently returned wrong parametrizations. Fix the three issues of that code: build the bordered sequence from the points after undoing their mirroring, clear the polynomial used as scratch space by nmod_em_gcd_preinstantiated before filling it again, and recover the solutions of the original system from the bordered generators. invert_hankel_matrix now returns 2 in the bordered case so that solve_hankel can apply this correction. This was the cause of the random failure of diff_cyclic5-16.sh seen in CI with SEED=1790795968. Add a regression test with that seed; it exercises the degenerate case with glibc's rand(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wegank
force-pushed
the
fix-hankel-degenerate-minimal
branch
from
September 30, 2026 23:22
a9241ff to
17a95be
Compare
mohabsafey
approved these changes
Oct 1, 2026
mohabsafey
left a comment
Contributor
There was a problem hiding this comment.
It's ok for me but maybe @jerebertho you could also have a look since you know this part better than me
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.
This PR is entirely prepared by Claude Code. Below is the commit message.
Fixes #331.
Fixes #368.
The parametrizations in shape position are obtained by solving Hankel systems with a Gohberg-Semencul type formula, which requires the constant coefficient of the first generator Z1 to be nonzero. For a random sequence this fails with probability about 1/p, when a sub-block of size dim - 1 of the Hankel matrix is singular. The code handling this case borders the Hankel matrix into one of size dim + 1, for which the formula applies, but it silently returned wrong parametrizations.
Fix the three issues of that code: build the bordered sequence from the points after undoing their mirroring, clear the polynomial used as scratch space by nmod_em_gcd_preinstantiated before filling it again, and recover the solutions of the original system from the bordered generators. invert_hankel_matrix now returns 2 in the bordered case so that solve_hankel can apply this correction.
This was the cause of the random failure of diff_cyclic5-16.sh seen in CI with SEED=1790795968. Add a regression test with that seed; it exercises the degenerate case with glibc's rand().