| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| if not s: | ||
| return s | ||
| # XXX: check invertibility? | ||
| x = nmod_div(sval, tval, mod) |
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
There is such a function: n_gcdinv.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks. I've added this in #79
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
These are minimal fixes needed for SymPy to be able to use nmod.