does someone knows a simple library to do
calculations on Polynomial with modular coefficients?
I've seen numpy, but this one seems like it does not support modular coefficients...
Thanks, Shai.
does someone knows a simple library to do
calculations on Polynomial with modular coefficients?
I've seen numpy, but this one seems like it does not support modular coefficients...
Thanks, Shai.
It suffices to lift coefficients to integers. For example if you want to compute
(1+2x+3x^2)(3+2x+x^2)
in Z/5[x]
, simply you compute (1+2x+3x^2)(3+2x+x^2)
in Z[x]
and reduce it to Z/5[x]
.
Thus
>>> import numpy.polynomial.polynomial
>>> c1 = (1,2,3)
>>> c2 = (3,2,1)
>>> numpy.fmod(numpy.polynomial.polynomial.polymul(c1,c2),5)
>>> numpy.fmod(numpy.polynomial.polynomial.polymul(c1,c2),5)
gives
array([ 3., 3., 4., 3., 3.])