update hensel.py
This commit is contained in:
parent
a3e31fb0db
commit
9f75e71c3e
2 changed files with 10 additions and 1 deletions
|
@ -3,6 +3,14 @@
|
||||||
from padic import *
|
from padic import *
|
||||||
from poly import *
|
from poly import *
|
||||||
|
|
||||||
|
def roots(p, poly):
|
||||||
|
'Yield all roots of polynomial in the given p-adic integers.'
|
||||||
|
for root in xrange(p):
|
||||||
|
try:
|
||||||
|
yield PAdicPoly(p, poly, root)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
class PAdicPoly(PAdic):
|
class PAdicPoly(PAdic):
|
||||||
'Result of lifting a root of a polynomial in the integers mod p to the p-adic integers.'
|
'Result of lifting a root of a polynomial in the integers mod p to the p-adic integers.'
|
||||||
def __init__(self, p, poly, root):
|
def __init__(self, p, poly, root):
|
||||||
|
|
3
poly.py
3
poly.py
|
@ -19,7 +19,8 @@ class Poly:
|
||||||
def term(coeff, expt):
|
def term(coeff, expt):
|
||||||
if coeff == 1 and expt == 0:
|
if coeff == 1 and expt == 0:
|
||||||
return '1'
|
return '1'
|
||||||
return ' * '.join(([] if coeff == 1 else [str(coeff)]) + ([] if expt == 0 else ['X'] if expt == 1 else ['X ** ' + expt]))
|
return ' * '.join(([] if coeff == 1 else [str(coeff)]) + \
|
||||||
|
([] if expt == 0 else ['X'] if expt == 1 else ['X ** %d' % expt]))
|
||||||
|
|
||||||
return ' + '.join(term(self.coeffs[i], i) for i in self.coeffs if self.coeffs[i] != 0)
|
return ' + '.join(term(self.coeffs[i], i) for i in self.coeffs if self.coeffs[i] != 0)
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
Loading…
Reference in a new issue