Previously by default sqrt() from gmpy was used if gmpy was awailable
on the system and sqrt() from mpmath otherwise. However, there is no
need for such separation and isqrt() from libmpf will do the job.

Reported-by: Fredrik Johansson
Signed-off-by: Mateusz Paprocki
---
 sympy/polys/integerpolys.py |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/sympy/polys/integerpolys.py b/sympy/polys/integerpolys.py
index e312304..9aae0e1 100644
--- a/sympy/polys/integerpolys.py
+++ b/sympy/polys/integerpolys.py
@@ -15,16 +15,12 @@
 from random import randint
 
 from sympy.core.numbers import igcd, igcdex
+from sympy.mpmath.libmpf import isqrt
 
 INT_TYPE = int
 INT_ZERO = 0
 INT_ONE  = 1
 
-try:
-    from gmpy import sqrt as isqrt
-except ImportError:
-    from sympy.mpmath import sqrt as isqrt
-
 from copy import deepcopy
 
 def factorial(m):
@@ -1475,12 +1471,7 @@ def finalize(h, cff, cfg, gcd):
 
     B = 2*min(f_norm, g_norm) + 29
 
-    try:
-        C = INT_TYPE(isqrt(B))
-    except OverflowError:
-        raise HeuristicGCDFailed('need GMPY')
-
-    x = max(min(B, 99*C),
+    x = max(min(B, 99*INT_TYPE(isqrt(B))),
             2*min(f_norm // abs(poly_LC(f)),
                   g_norm // abs(poly_LC(g))) + 2)
 
@@ -1608,12 +1599,7 @@ def finalize(h, cff, cfg, gcd):
 
     B = 2*min(f_norm, g_norm) + 29
 
-    try:
-        C = INT_TYPE(isqrt(B))
-    except OverflowError:
-        raise HeuristicGCDFailed('need GMPY')
-
-    x = max(min(B, 99*C),
+    x = max(min(B, 99*INT_TYPE(isqrt(B))),
             2*min(f_norm // abs(zzX_zz_LC(f)),
                   g_norm // abs(zzX_zz_LC(g))) + 2)
 
-- 
1.6.1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to