FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Minor fixes for nmod by oscarbenjamin · Pull Request #78 · flintlib/python-flint · GitHub

Repository navigation

Minor fixes for nmod - #78

Merged
oscarbenjamin merged 1 commit into
flintlib:masterfrom
oscarbenjamin:pr_nmod
Sep 9, 2023
Merged

oscarbenjamin merged 1 commit into
flintlib:masterfrom
oscarbenjamin:pr_nmod

Conversation

Copy link
Copy Markdown
Collaborator

These are minimal fixes needed for SymPy to be able to use nmod.

Comment thread src/flint/types/nmod.pyx
if not s:
return s
# XXX: check invertibility?
x = nmod_div(sval, tval, mod)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This change makes it so that nmod(0, p) / nmod(a, p) gives nmod(0, p).

About invertibility: in the context of SymPy's use the modulus here will always be prime. Otherwise though if tval and mod are not coprime then this gives a core dump:

In [3]: flint.nmod(1, 6) / flint.nmod(3, 6)
Flint exception (Impossible inverse):
    Cannot invert modulo 3*0
Aborted (core dumped)

That is not very friendly in Python land but I am not sure if adding checks here for is worth it: you would need to compute gcd(tval, mod) and that calculation would always be unnecessary for prime mod. Ideally Flint should provide an efficient function that could return an error code rather than aborting.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There is such a function: n_gcdinv.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks. I've added this in #79

oscarbenjamin merged commit 9a86d4e into flintlib:master Sep 9, 2023
oscarbenjamin deleted the pr_nmod branch September 9, 2023 11:31
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL