Skip to content

Commit 3abc9aa

Browse files
committed
change polynomial_construction from the review, update description and add doctests
1 parent 4cfa750 commit 3abc9aa

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/sage/rings/polynomial/laurent_polynomial_mpair.pyx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,8 +1522,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
15221522

15231523
def polynomial_construction(self):
15241524
"""
1525-
Return a polynomial having no monomial as a factor
1526-
and the shift monomial.
1525+
Factor ``self`` into a polynomial and a monomial.
15271526
15281527
OUTPUT:
15291528
@@ -1535,16 +1534,27 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
15351534
sage: R.<x, y> = LaurentPolynomialRing(QQ)
15361535
sage: f = y / x + x^2 / y + 3 * x^4 * y^-2
15371536
sage: f.polynomial_construction()
1538-
(3*x^5 + x^3*y + y^3, x^-1*y^-2)
1537+
(3*x^5 + x^3*y + y^3, 1/(x*y^2))
1538+
sage: f = y * x + x^2 / y + 3 * x^4 * y^-2
1539+
sage: f.polynomial_construction()
1540+
(3*x^3 + y^3 + x*y, x/y^2)
1541+
sage: x.polynomial_construction()
1542+
(1, x)
1543+
sage: (y^-1).polynomial_construction()
1544+
(1, 1/y)
15391545
"""
1540-
R = self.parent()
1541-
n = R.ngens()
1542-
S = R.polynomial_ring()
1543-
if not self:
1544-
return (self, R(1))
1545-
minimo = tuple(min(a[1].degree(v) for a in self) for v in R.gens())
1546-
mon = R({minimo: 1})
1547-
return (S(mon ** -1 * self), mon)
1546+
self._normalize()
1547+
ring = self._parent._R
1548+
g = ring.gens()
1549+
mon = ring.prod(g[i] ** j for i, j in enumerate(self._mon))
1550+
return (self._poly, mon) # R = self.parent()
1551+
# n = R.ngens()
1552+
# S = R.polynomial_ring()
1553+
# if not self:
1554+
# return (self, R(1))
1555+
# minimo = tuple(min(a[1].degree(v) for a in self) for v in R.gens())
1556+
# mon = R({minimo: 1})
1557+
# return (S(mon ** -1 * self), mon)
15481558

15491559
def factor(self):
15501560
"""

0 commit comments

Comments
 (0)