#13166: Compute q-binomial coefficients more efficiently
---------------------------------+------------------------------------------
       Reporter:  arminstraub    |         Owner:  sage-combinat    
           Type:  enhancement    |        Status:  positive_review  
       Priority:  minor          |     Milestone:  sage-5.2         
      Component:  combinatorics  |    Resolution:                   
       Keywords:                 |   Work issues:                   
Report Upstream:  N/A            |     Reviewers:  Javier López Peña
        Authors:  Armin Straub   |     Merged in:                   
   Dependencies:                 |      Stopgaps:                   
---------------------------------+------------------------------------------
Changes (by jlopez):

  * status:  needs_review => positive_review


Old description:

> Currently, q-binomials are calculated as a fraction of products of
> q-integers.  With the attached patch, q-binomials are computed as a
> product of cyclotomic polynomials.  This avoids reducing a fraction of
> polynomials and is significantly faster for larger q-binomial
> coefficients.
>
> Before:
> {{{
> sage: from sage.combinat.q_analogues import *
> sage: %timeit q_binomial(18,7)
> 125 loops, best of 3: 1.89 ms per loop
> sage: %timeit q_binomial(180,70)
> 5 loops, best of 3: 1.4 s per loop
> }}}
>
> After:
> {{{
> sage: from sage.combinat.q_analogues import *
> sage: %timeit q_binomial(18,7)
> 125 loops, best of 3: 2.01 ms per loop
> sage: %timeit q_binomial2(180,70)
> 25 loops, best of 3: 34.7 ms per loop
> }}}

New description:

 Currently, q-binomials are calculated as a fraction of products of
 q-integers.  With the attached patch, q-binomials are computed as a
 product of cyclotomic polynomials.  This avoids reducing a fraction of
 polynomials and is significantly faster for larger q-binomial
 coefficients.

 Before:
 {{{
 sage: from sage.combinat.q_analogues import *
 sage: %timeit q_binomial(18,7)
 125 loops, best of 3: 1.89 ms per loop
 sage: %timeit q_binomial(180,70)
 5 loops, best of 3: 1.4 s per loop
 }}}

 After:
 {{{
 sage: from sage.combinat.q_analogues import *
 sage: %timeit q_binomial(18,7)
 125 loops, best of 3: 2.01 ms per loop
 sage: %timeit q_binomial2(180,70)
 25 loops, best of 3: 34.7 ms per loop
 }}}

 Apply [attachment:trac_13166_q_binomials.patch] and
 [attachment:trac_13166_q_binomials_reference.patch]

--

Comment:

 You are correct, I tend to mess up the markup every now and then... ;-)
 Code still looks good, test still pass, and patchbot seems happy, so
 positive review!

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13166#comment:7>
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