Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium EasyToFix

New issue 3516 by [email protected]: gcd for Rationals is much slower than it should be
http://code.google.com/p/sympy/issues/detail?id=3516

There is a routine in Mul (at the bottom) named _rgcd that computes the Rational gcd much faster than the current gcd() or .gcd() involving only Rationals.

    timeit('gcd(S.Half,S.Half/2)','from sympy import S,gcd',number=1000)
    0.52889084815979
    >>> timeit('S.Half.gcd(S.Half/2)','from sympy import S',number=1000)
    0.4783451557159424
    >>> timeit('Rational(igcd(a.p,b.p),ilcm(a.q,b.q)),S.Half,S.Half/2','from
    ... sympy import ilcm, igcd, Rational, S\na = S.Half; b=a/2;
    ... c=a*4;d=a*5',number=1000)
    0.05577492713928223

Right now, the .gcd() involving Rationals uses the default definition in Number; it should probably have it's own method in Rational or a smarting function in polytools.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to