Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fixing some conflicts between Jeroen's and Julian's changes
Browse files Browse the repository at this point in the history
  • Loading branch information
roed314 committed Jan 4, 2014
1 parent 8c58b70 commit 49fae49
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 124 deletions.
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/padics/polynomial_padic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Polynomial_padic(Polynomial_generic_domain):
.. NOTE::
In contrast to :class:`polynomial_padic.Polynomial_padic_generic`
In contrast to :class:`polynomial_padic_generic.Polynomial_padic_generic`
(which inherits from this class), this class is meant as a base class
for implementations which provide their own handling of the polynomial
data.
Expand Down
121 changes: 1 addition & 120 deletions src/sage/rings/polynomial/padics/polynomial_padic_flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, ab
m = sage.rings.padics.misc.min(a.precision_absolute() for a in x.values())
if not absprec is None:
m = min(m, absprec)
Polynomial_generic_dense_ring.__init__(self, parent, x, absprec = m)
Polynomial_padic_generic_ring.__init__(self, parent, x, absprec = m)
return
elif isinstance(x, pari_gen):
x = [R(w) for w in x.list()]
Expand All @@ -109,122 +109,3 @@ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, ab
absprec = infinity
m = min([a.precision_absolute() for a in x] + [absprec])
Polynomial_padic_generic_ring.__init__(self, parent, x)

def _mul_(self, right):
"""
Returns the product of this Polynomial_padic_flat by right.
"""
return self._mul_generic(right)

def _repr(self, name=None):
r"""
EXAMPLES:
sage: R.<w> = PolynomialRing(Zp(5, prec=5, type = 'capped-abs', print_mode = 'val-unit'))
sage: f = 24 + R(4/3)*w + w^4
sage: f._repr()
'(1 + O(5^5))*w^4 + (1043 + O(5^5))*w + (24 + O(5^5))'
sage: f._repr(name='z')
'(1 + O(5^5))*z^4 + (1043 + O(5^5))*z + (24 + O(5^5))'
AUTHOR:
-- David Roe (2007-03-03), based on Polynomial_generic_dense._repr()
"""
s = " "
n = m = self.degree()
if name is None:
name = self.parent().variable_name()
#atomic_repr = self.parent().base_ring()._repr_option('element_is_atomic')
coeffs = self.list()
for x in reversed(coeffs):
if x != 0:
if n != m:
s += " + "
#x = repr(x)
x = "(%s)"%x
if n > 1:
var = "*%s^%s"%(name,n)
elif n==1:
var = "*%s"%name
else:
var = ""
s += "%s%s"%(x,var)
n -= 1
if s==" ":
return "0"
return s[1:]

def factor(self, absprec = None):
r"""
Returns the factorization of this Polynomial_padic_flat.
EXAMPLES:
sage: R.<w> = PolynomialRing(Zp(5, prec=5, type = 'capped-abs', print_mode = 'val-unit'))
sage: f = w^5-1
sage: f.factor()
((1 + O(5^5))*w + (624 + O(5^5))) * ((1 + O(5^5))*w^4 + (2501 + O(5^5))*w^3 + (1876 + O(5^5))*w^2 + (1251 + O(5^5))*w + (626 + O(5^5)))
See \#4038:
sage: E = EllipticCurve('37a1')
sage: K =Qp(7,10)
sage: EK = E.base_extend(K)
sage: E = EllipticCurve('37a1')
sage: K = Qp(7,10)
sage: EK = E.base_extend(K)
sage: g = EK.division_polynomial_0(3)
sage: g.factor()
(3 + O(7^10)) * ((1 + O(7^10))*x + (1 + 2*7 + 4*7^2 + 2*7^3 + 5*7^4 + 7^5 + 5*7^6 + 3*7^7 + 5*7^8 + 3*7^9 + O(7^10))) * ((1 + O(7^10))*x^3 + (6 + 4*7 + 2*7^2 + 4*7^3 + 7^4 + 5*7^5 + 7^6 + 3*7^7 + 7^8 + 3*7^9 + O(7^10))*x^2 + (6 + 3*7 + 5*7^2 + 2*7^4 + 7^5 + 7^6 + 2*7^8 + 3*7^9 + O(7^10))*x + (2 + 5*7 + 4*7^2 + 2*7^3 + 6*7^4 + 3*7^5 + 7^6 + 4*7^7 + O(7^10)))
TESTS:
Check that :trac:`13293` is fixed::
sage: R.<T>=Qp(3)[]
sage: f=1926*T^2 + 312*T + 387
sage: f.factor()
(1 + 2*3 + 2*3^2 + 3^3 + 2*3^4 + O(3^20)) * ((3 + O(3^21))) * ((1 + O(3^20))*T + (2*3 + 3^2 + 3^3 + 3^5 + 2*3^6 + 2*3^7 + 3^8 + 3^10 + 3^11 + 2*3^12 + 2*3^14 + 2*3^15 + 2*3^17 + 2*3^18 + 3^20 + O(3^21))) * ((3 + O(3^21))*T + (2 + 3^2 + 3^3 + 2*3^6 + 2*3^7 + 2*3^8 + 3^9 + 3^10 + 2*3^12 + 3^16 + 3^18 + O(3^20)))
"""
if self == 0:
raise ValueError, "Factorization of 0 not defined"
if absprec is None:
absprec = min([x.precision_absolute() for x in self.list()])
else:
absprec = Integer(absprec)
if absprec <= 0:
raise ValueError, "absprec must be positive"
G = self._pari_().factorpadic(self.base_ring().prime(), absprec)
pols = G[0]
exps = G[1]
F = []
R = self.parent()
for i in xrange(len(pols)):
f = R(pols[i], absprec = absprec)
e = int(exps[i])
F.append((f,e))

#if R.base_ring().is_field():
# # When the base ring is a field we normalize
# # the irreducible factors so they have leading
# # coefficient 1.
# for i in range(len(F)):
# cur = F[i][0].leading_coefficient()
# if cur != 1:
# F[i] = (F[i][0].monic(), F[i][1])
# return Factorization(F, self.leading_coefficient())
#else:
# # When the base ring is not a field, we normalize
# # the irreducible factors so that the leading term
# # is a power of p. We also ensure that the gcd of
# # the coefficients of each term is 1.
c = self.leading_coefficient().valuation()
u = self.base_ring()(1)
for i in range(len(F)):
upart = F[i][0].leading_coefficient().unit_part().lift_to_precision(absprec)
lval = F[i][0].leading_coefficient().valuation()
if upart != 1:
F[i] = (F[i][0] / upart, F[i][1])
u *= upart ** F[i][1]
c -= lval * F[i][1]
if c != 0:
F.append((self.parent()(self.base_ring().prime_pow(c)), 1))
u = u.add_bigoh(absprec - c)
return Factorization(F, u)
5 changes: 2 additions & 3 deletions src/sage/rings/polynomial/padics/polynomial_padic_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# http://www.gnu.org/licenses/
#*****************************************************************************
from sage.rings.polynomial.polynomial_element import Polynomial_generic_dense
from sage.rings.polynomial.polynomial_element_generic import Polynomial_generic_dense_field, Polynomial_generic_domain
from sage.rings.polynomial.polynomial_element_generic import Polynomial_generic_dense_field
from polynomial_padic import Polynomial_padic

class Polynomial_padic_generic_ring(Polynomial_padic, Polynomial_generic_domain, Polynomial_generic_dense):
class Polynomial_padic_generic_ring(Polynomial_padic, Polynomial_generic_dense):
r"""
A polynomial over a `p`-adic ring which is not a field.
Expand Down Expand Up @@ -65,7 +65,6 @@ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, ab
"""
Polynomial_padic.__init__(self, parent, is_gen=is_gen)
Polynomial_generic_domain.__init__(self, parent, is_gen=is_gen)
Polynomial_generic_dense.__init__(self, parent, x)

class Polynomial_padic_generic_field(Polynomial_padic, Polynomial_generic_dense_field):
Expand Down

0 comments on commit 49fae49

Please sign in to comment.