0

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.

buc030
  • 425
  • 3
  • 14

1 Answers1

0

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.])
Dada
  • 6,313
  • 7
  • 24
  • 43
Ed.B
  • 465
  • 4
  • 4