Add Unique Hess Jacobian model, and some cleanup to function fields code#41453
Merged
vbraun merged 67 commits intosagemath:developfrom Feb 25, 2026
Merged
Add Unique Hess Jacobian model, and some cleanup to function fields code#41453vbraun merged 67 commits intosagemath:developfrom
vbraun merged 67 commits intosagemath:developfrom
Conversation
|
Documentation preview for this PR (built with commit cac3ded; changes) is ready! 🎉 |
Member
Author
|
@kwankyu Would you be able to review this? |
kwankyu
reviewed
Feb 19, 2026
kwankyu
reviewed
Feb 19, 2026
kwankyu
approved these changes
Feb 20, 2026
Collaborator
kwankyu
left a comment
There was a problem hiding this comment.
LGTM. I am happy that existing doctests not only pass but also often run faster than previously.
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Feb 20, 2026
sagemathgh-41453: Add Unique Hess Jacobian model, and some cleanup to function fields code <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> This PR adds an optimized polished implementation of the Unique Hess Jacobian model from [my Master's thesis](https://ucalgary.scholaris.ca/i tems/00115cc7-cf9d-49d9-9185-77d3eb2d58e7). This model is similar to the existing Hess model we have, but uses a different algorithm for reduction that gives unique representatives of divisor classes. The existing Hess model and Khuri-Makdisi models that are already in Sage do not give unique representatives, and so are not hashable and cannot be used in sets or dictionaries (we previously had an incorrect hash implementation for these models which I removed because they are inherently not hashable). In order to minimize duplication with the existing Hess model I moved some the `_normalize` method to a new Cython file, which should also speed it up. I made a few other refactoring changes along the way to simplify the code, especially by moving generic code to the `FunctionField` class that was previously repeated in `RationalFunctionField` and `FunctionField_polymod`. I also added a lot of type annotation to the function fields code. Despite all the refactoring, the only breaking changes are deprecations of unnecessary functions (and removal of the broken hash functions for the Hess and Khuri-Makdisi models). For example, Jacobian elements had a `multiple` method that does the same thing as `self * n`, so I deprecated that (after fixing some coercion issues that make `n * self` slower than it should have been). For reviewers: pretty much all the "new" code is in `src/sage/rings/function_field/jacobian_unique_hess.py` and everything else is refactoring/optimization (and some changes to the `jacobian` method in `src/sage/rings/function_field/function_field.py` to add the ability to construct the new Jacobian model). I'm submitting it as one PR rather than two so that there is context for why I'm refactoring the code. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#41453 Reported by: Vincent Macri Reviewer(s): Kwankyu Lee, Vincent Macri
Member
Author
Thank you so much for the review! |
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 adds an optimized polished implementation of the Unique Hess Jacobian model from my Master's thesis. This model is similar to the existing Hess model we have, but uses a different algorithm for reduction that gives unique representatives of divisor classes. The existing Hess model and Khuri-Makdisi models that are already in Sage do not give unique representatives, and so are not hashable and cannot be used in sets or dictionaries (we previously had an incorrect hash implementation for these models which I removed because they are inherently not hashable).
In order to minimize duplication with the existing Hess model I moved some the
_normalizemethod to a new Cython file, which should also speed it up. I made a few other refactoring changes along the way to simplify the code, especially by moving generic code to theFunctionFieldclass that was previously repeated inRationalFunctionFieldandFunctionField_polymod. I also added a lot of type annotation to the function fields code.Despite all the refactoring, the only breaking changes are deprecations of unnecessary functions (and removal of the broken hash functions for the Hess and Khuri-Makdisi models). For example, Jacobian elements had a
multiplemethod that does the same thing asself * n, so I deprecated that (after fixing some coercion issues that maken * selfslower than it should have been).For reviewers: pretty much all the "new" code is in
src/sage/rings/function_field/jacobian_unique_hess.pyand everything else is refactoring/optimization (and some changes to thejacobianmethod insrc/sage/rings/function_field/function_field.pyto add the ability to construct the new Jacobian model). I'm submitting it as one PR rather than two so that there is context for why I'm refactoring the code.📝 Checklist
⌛ Dependencies