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

Commit 4aba8a9

Browse files
committed
21517: avoid duplicate computations
1 parent de1acfa commit 4aba8a9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/sage/rings/integer.pyx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,14 +2572,16 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
25722572
return RealField(prec)(self).log()
25732573
return RealField(prec)(self).log(m)
25742574

2575-
if (type(m) == Integer and type(self) == Integer
2576-
and m**(self.exact_log(m)) == self):
2577-
return self.exact_log(m)
2575+
if type(m) == Integer and type(self) == Integer:
2576+
elog = self.exact_log(m)
2577+
if m**elog == self:
2578+
return elog
25782579

25792580
if (type(m) == Rational and type(self) == Integer
2580-
and m.numer() == 1
2581-
and m**(-self.exact_log(m.denom())) == self):
2582-
return -self.exact_log(m.denom())
2581+
and m.numer() == 1):
2582+
elog = -self.exact_log(m.denom())
2583+
if m**elog == self:
2584+
return elog
25832585

25842586
from sage.symbolic.all import SR
25852587
from sage.functions.log import function_log

0 commit comments

Comments
 (0)