| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
We want the tests to still pass on 32 bit (gh-317).
Since gh-318 there is the pyodide job which runs on wasm32 although it would still be good to have a proper i686 job to test things like this. |
Sorry, something went wrong.
|
Looks like arb_poly and acb_poly have mullow but not pow_trunc. If at least all the exact poly types have these methods now then they can be added to this typing protocol: python-flint/src/flint/typing.py Lines 139 to 145 in d5c40a4 |
Sorry, something went wrong.
| :math:`f^e \mod x^n`/ | ||
|
|
||
| Note: For exponents larger that 2^63 (which do not fit inside a slong) use the | ||
| method :meth:`~.pow_mod` with the explicit modulus `x^n`. |
There was a problem hiding this comment.
Maybe the code here could test for overflow and call pow_mod.
Sorry, something went wrong.
|
New proposal :
The proposal is to not use modular pow (which is not defined for fmpz/fmpq) and implement "manually" large exponents using a loop (it works even for fmpz/fmpq and it is 2x-3x faster than powmod). I hope it is not overkill (I'm not sure there is a lot of use for large powers of fmpz_poly, maybe for combinatorics?) |
Sorry, something went wrong.
I'm not sure either but it is good to have an implementation that does not have an arbitrary upper limit on the exponent as long as higher powers are computable. It took me a while to parse the code used for this but it looks good: def pow(x, e):
ebytes = e.to_bytes((e.bit_length() + 15) // 16 * 2, "nig")
p = x ** (ebytes[0] * 256 + ebytes[1])
for i in range(2, len(ebytes), 2):
p = p ** (1 << 16)
p = p * x ** (ebytes[i] * 256 + ebytes[i + 1])
return pI guess that is going to reduce the overhead a little compared to working through e one bit at a time (which is ultimately what e.g. fmpz_poly_pow_trunc ends up doing after a bit of preprocessing). The series types can also be used for this but they also have the overflow problem so I guess the same approach could be used there: In [1]: import flint
In [2]: f = flint.fmpz_series([1, 2, 3], prec=3)
In [3]: f
Out[3]: 1 + 2*x + 3*x^2 + O(x^3)
In [4]: f ** (5 ** 25)
Out[4]: 1 + 596046447753906250*x + 177635683940025046765804290771484375*x^2 + O(x^3)
In [5]: f ** (5 ** 30)
---------------------------------------------------------------------------
OverflowError |
Sorry, something went wrong.
|
Looks good to me. Thanks |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
These methods already exist on fmpz_mod_poly and fq_default_poly.
Additionally, the existing docstrings and doctests are updated to assume the upper bound of slong is 2^63. Let me know if this is not fine (current all configured Github runners are 64-bit platforms). I am unsure whether 64-bit specific tests are fine.