~dinko-metalac/calculus-app2/trunk

« back to all changes in this revision

Viewing changes to lib/py/sympy/polys/heuristicgcd.py

  • Committer: dinko.metalac at gmail
  • Date: 2015-04-14 13:28:14 UTC
  • Revision ID: dinko.metalac@gmail.com-20150414132814-j25k3qd7sq3warup
new sympy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""Heuristic polynomial GCD algorithm (HEUGCD). """
2
2
 
 
3
from __future__ import print_function, division
 
4
from sympy.core.compatibility import xrange
 
5
from .polyerrors import HeuristicGCDFailed
 
6
 
3
7
HEU_GCD_MAX = 6
4
8
 
5
9
def heugcd(f, g):
67
71
            2*min(f_norm // abs(f.LC),
68
72
                  g_norm // abs(g.LC)) + 2)
69
73
 
70
 
    for i in range(0, HEU_GCD_MAX):
 
74
    for i in xrange(0, HEU_GCD_MAX):
71
75
        ff = f.evaluate(x0, x)
72
76
        gg = g.evaluate(x0, x)
73
77
 
137
141
 
138
142
            # f += X**i*g
139
143
            if g:
140
 
                for monom, coeff in g.terms():
 
144
                for monom, coeff in g.iterterms():
141
145
                    f[(i,) + monom] = coeff
142
146
            i += 1
143
147