#13441: refactor gcd
------------------------------------+---------------------------------------
       Reporter:  saraedum          |         Owner:  AlexGhitza  
           Type:  task              |        Status:  needs_review
       Priority:  trivial           |     Milestone:  sage-5.4    
      Component:  basic arithmetic  |    Resolution:              
       Keywords:                    |   Work issues:              
Report Upstream:  N/A               |     Reviewers:              
        Authors:  Julian Rueth      |     Merged in:              
   Dependencies:                    |      Stopgaps:              
------------------------------------+---------------------------------------
Changes (by saraedum):

  * status:  needs_info => needs_review


Comment:

 Without the patch I get:
 {{{
 sage: x,y=34912364,123324234
 sage: timeit('x.gcd(y)')
 625 loops, best of 3: 430 ns per loop
 sage: x,y=234/234525,4324525/12351
 sage: timeit('x.gcd(y)')
 625 loops, best of 3: 11.5 µs per loop
 sage: R.<T>=ZZ[]
 sage: x,y=123*T^2+23424*T+1231,1231451*T^3+65*T^2+352*T+234251
 sage: timeit('x.gcd(y)')
 625 loops, best of 3: 6.06 µs per loop
 }}}

 With the patch:
 {{{
 sage: x,y=34912364,123324234
 sage: timeit('x.gcd(y)')
 625 loops, best of 3: 1.13 µs per loop
 sage: x,y=234/234525,4324525/12351
 sage: timeit('x.gcd(y)')
 625 loops, best of 3: 14.1 µs per loop
 sage: R.<T>=ZZ[]
 sage: x,y=123*T^2+23424*T+1231,1231451*T^3+65*T^2+352*T+234251
 sage: timeit('x.gcd(y)')
 625 loops, best of 3: 6.21 µs per loop
 }}}

 So there is actually a speed penalty. This seems to be caused by a bug in
 {{{coerce_binop}}}:

 {{{
 sage: x.gcd
 <sage.structure.element.NamedBinopMethod object at 0x1bc255f0>
 sage: x.gcd
 <sage.structure.element.NamedBinopMethod object at 0x1bc27290>
 }}}

 I'm looking into this.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13441#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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/sage-trac?hl=en.

Reply via email to