This commit is contained in:
parent
0cfc2d3066
commit
87662b3399
1 changed files with 18 additions and 0 deletions
18
poly.py
Normal file
18
poly.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Finding roots of polynomials in p-adic integers using Hensel's lemma
|
||||||
|
|
||||||
|
from padic import *
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
class Poly:
|
||||||
|
'Polynomial class.'
|
||||||
|
def __init__(self, coeffs = None):
|
||||||
|
self.coeffs = defaultdict(int, coeffs or {})
|
||||||
|
self.deg = 0
|
||||||
|
# TODO arithmetic
|
||||||
|
|
||||||
|
X = Poly({1:1})
|
||||||
|
|
||||||
|
class ConstPoly(Poly):
|
||||||
|
'Constant polynomial.'
|
||||||
|
def __init__(self, coeff):
|
||||||
|
Poly.__init__(self, {0:coeff})
|
Loading…
Reference in a new issue