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

Commit

Permalink
Trac #20086: powers of constant polynomials over ZZ
Browse files Browse the repository at this point in the history
  • Loading branch information
cheuberg committed Feb 19, 2016
1 parent cc49098 commit 25fdd0c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx
Expand Up @@ -1003,7 +1003,31 @@ cdef class Polynomial_integer_dense_flint(Polynomial):
Traceback (most recent call last):
...
OverflowError: Sage Integer too large to convert to C long
"""
If this polynomial is constant, hand over to the base ring
(:trac:`20086`)::
sage: P.<R> = ZZ[]
sage: P(1)^(1/3)
1
sage: _.parent()
Univariate Polynomial Ring in R over Integer Ring
sage: P(4)^(1/2)
2
sage: _.parent()
Univariate Polynomial Ring in R over Integer Ring
sage: P(3)^(1/2)
sqrt(3)
sage: _.parent()
Symbolic Ring
"""
if fmpz_poly_degree(self.__poly) == 0:
result = self[0]**exp
try:
return self.parent()(result)
except TypeError:
return result

cdef Polynomial_integer_dense_flint res = self._new()
cdef long nn = pyobject_to_long(exp)

Expand Down

0 comments on commit 25fdd0c

Please sign in to comment.