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

Commit

Permalink
16516: Better use of sig_on/sig_off
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrenet committed May 19, 2017
1 parent 080a617 commit 6bdb88f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/sage/rings/integer_ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1322,25 +1322,26 @@ cdef class IntegerRing_class(PrincipalIdealDomain):
else:
p = p.parent()(p/p.content())

cdef list roots = []

# The dense algorithm is to compute the roots from the factorization
if algorithm == "dense":
return p._roots_from_factorization(p.factor(), multiplicities)

sig_on()
sig_on()
roots = p._roots_from_factorization(p.factor(), multiplicities)
sig_off()
return roots

v = p.valuation()
p = p.shift(-v)

# Root 0
cdef list roots = []
if v>0:
if multiplicities: roots = [(self.zero(), v)]
else: roots = [self.zero()]
else:
roots = []

if p.is_constant():
sig_off()
return roots

cdef list c = p.coefficients()
Expand All @@ -1349,8 +1350,10 @@ cdef class IntegerRing_class(PrincipalIdealDomain):

# totally dense polynomial
if k == 1 + p.degree():
sig_on()
roots = p._roots_from_factorization(p.factor(), multiplicities)
sig_off()
return p._roots_from_factorization(p.factor(), multiplicities)
return roots

K = p.base_ring()
x = p.variable_name()
Expand All @@ -1373,6 +1376,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain):

# if no gap, directly return the roots of p
if g.is_zero():
sig_on()
roots.extend(p._roots_from_factorization(p.factor(), multiplicities))
sig_off()
return roots
Expand Down Expand Up @@ -1429,11 +1433,14 @@ cdef class IntegerRing_class(PrincipalIdealDomain):

# Add roots of modulus > 1 to `roots`:
if multiplicities:
sig_on()
roots.extend(r for r in g._roots_from_factorization(g.factor(), True) if r[0].abs() > 1)
sig_off()
else:
sig_on()
roots.extend(r for r in g._roots_from_factorization(g.factor(), False) if r.abs() > 1)
sig_off()

sig_off()
return roots


Expand Down

0 comments on commit 6bdb88f

Please sign in to comment.