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

Commit 556a7ea

Browse files
author
Sebastian Oehms
committed
initial version
1 parent a1bfef8 commit 556a7ea

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

src/sage/rings/polynomial/laurent_polynomial_ring.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,23 @@ def _ideal_class_(self, n=0):
706706
# One may eventually want ideals in these guys.
707707
raise NotImplementedError
708708

709-
def ideal(self):
709+
def ideal(self, *args, **kwds):
710710
"""
711711
EXAMPLES::
712712
713-
sage: LaurentPolynomialRing(QQ,2,'x').ideal()
713+
sage: LaurentPolynomialRing(QQ,2,'x').ideal([1])
714+
Traceback (most recent call last):
715+
...
716+
NotImplementedError
717+
718+
TESTS:
719+
720+
check that trac:`26421` is fixed:
721+
722+
sage: R.<t> = LaurentPolynomialRing(ZZ)
723+
sage: P.<x> = PolynomialRing(R)
724+
sage: p = x-t
725+
sage: p.content_ideal() # indirect doctest
714726
Traceback (most recent call last):
715727
...
716728
NotImplementedError

src/sage/rings/polynomial/polynomial_element.pyx

+40-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ AUTHORS:
2828
2929
- David Zureick-Brown (2017-09): Added is_weil_polynomial.
3030
31+
- Sebastian Oehms (2018-10): made :meth:`roots` and :meth:`factor` work over more
32+
cases of proper integral domains (see :trac:`26421`)
33+
3134
TESTS::
3235
3336
sage: R.<x> = ZZ[]
@@ -4195,6 +4198,14 @@ cdef class Polynomial(CommutativeAlgebraElement):
41954198
sage: x2 = ZZ['x']['x'].gen()
41964199
sage: (x1 - x2).factor()
41974200
-x + x
4201+
4202+
Check that :trac:`26421' is fixed::
4203+
4204+
sage: R.<t> = LaurentPolynomialRing(ZZ)
4205+
sage: P.<x> = R[]
4206+
sage: p = x**3 -(t**3+t**(-3))*x**2 -t**2*x + ~t +t**5
4207+
sage: p.factor()
4208+
(t^-3) * (t^3*x - 1 - t^6) * (x - t) * (x + t)
41984209
"""
41994210
# PERFORMANCE NOTE:
42004211
# In many tests with SMALL degree PARI is substantially
@@ -4341,6 +4352,16 @@ cdef class Polynomial(CommutativeAlgebraElement):
43414352
F.sort()
43424353
return F
43434354
except (TypeError, AttributeError):
4355+
if R.is_integral_domain() and not R.is_field():
4356+
from sage.rings.fraction_field import FractionField_generic
4357+
try:
4358+
F = FractionField_generic(R)
4359+
PF = F[self.variable_name()]
4360+
pol_frac = PF(self)
4361+
return pol_frac.factor(**kwargs).base_change(self.parent())
4362+
except:
4363+
pass
4364+
43444365
raise NotImplementedError
43454366

43464367
return self._factor_pari_helper(G, n)
@@ -7605,9 +7626,19 @@ cdef class Polynomial(CommutativeAlgebraElement):
76057626
sage: eq = x^6+x-17
76067627
sage: eq.roots(multiplicities=False)
76077628
[3109038, 17207405]
7629+
7630+
Check that :trac:`26421' is fixed::
7631+
7632+
sage: R.<t> = LaurentPolynomialRing(ZZ)
7633+
sage: P.<x> = R[]
7634+
sage: p = x**3 -(t**3+t**(-3))*x**2 -t**2*x + ~t +t**5
7635+
sage: p.roots()
7636+
[(t^-3 + t^3, 1), (t, 1), (-t, 1)]
76087637
"""
76097638
from sage.rings.finite_rings.finite_field_constructor import GF
76107639
K = self._parent.base_ring()
7640+
7641+
76117642
# If the base ring has a method _roots_univariate_polynomial,
76127643
# try to use it. An exception is raised if the method does not
76137644
# handle the current parameters
@@ -7818,10 +7849,14 @@ cdef class Polynomial(CommutativeAlgebraElement):
78187849
# get rid of the content of self since we don't need it
78197850
# and we really don't want to factor it if it's a huge
78207851
# integer
7821-
c = self.content()
7852+
c = self.content_ideal().gen()
78227853
self = self//c
7823-
except AttributeError:
7824-
pass
7854+
except (AttributeError, NotImplementedError):
7855+
try:
7856+
c = lcm(self.coefficients())
7857+
self = self/c
7858+
except:
7859+
pass
78257860
return self._roots_from_factorization(self.factor(), multiplicities)
78267861
else:
78277862
raise NotImplementedError
@@ -9076,7 +9111,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
90769111
# Be careful with the content: return the
90779112
# radical of the content times the radical of
90789113
# (self/content)
9079-
content = self.content()
9114+
content = self.content_ideal().gen()
90809115
self_1 = (self//content)
90819116
return (self_1 // self_1.gcd(self_1.derivative())) * content.radical()
90829117
else: # The above method is not always correct (see Trac 8736)
@@ -10156,6 +10191,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
1015610191
phi = SpecializationMorphism(self._parent,D)
1015710192
return phi(self)
1015810193

10194+
1015910195
def _log_series(self, long n):
1016010196
r"""
1016110197
Return the power series expansion of logarithm of this polynomial,

0 commit comments

Comments
 (0)