#15269: Speeding up tableau's cells_containing and weight methods
-------------------------------------+--------------------------------
       Reporter:  darij              |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  minor              |    Milestone:  sage-5.13
      Component:  combinatorics      |   Resolution:
       Keywords:  tableau, combinat  |    Merged in:
        Authors:  Darij Grinberg     |    Reviewers:  Travis Scrimshaw
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
   Dependencies:                     |     Stopgaps:
-------------------------------------+--------------------------------
Changes (by tscrim):

 * reviewer:   => Travis Scrimshaw


Old description:

> I know that the current implementation of tableaux in Sage is not long
> for this world (mutability WTF), but here are two small pieces of simple
> code that can be improved:
> Before:
> {{{
> sage: %timeit
> Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).cells_containing(4)
> 1000 loops, best of 3: 449 us per loop
> }}}
> After:
> {{{
> sage: %timeit
> Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).cells_containing(4)
> 10000 loops, best of 3: 81.5 us per loop
> }}}
> Before:
> {{{
> sage: %timeit
> Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).weight()
> 10000 loops, best of 3: 190 us per loop
> }}}
> After:
> {{{
> sage: %timeit
> Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).weight2()
> 10000 loops, best of 3: 87.4 us per loop
> }}}

New description:

 I know that the current implementation of tableaux in Sage is not long for
 this world (mutability WTF), but here are two small pieces of simple code
 that can be improved:
 Before:
 {{{
 sage: %timeit
 
Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).cells_containing(4)
 1000 loops, best of 3: 449 us per loop
 }}}
 After:
 {{{
 sage: %timeit
 
Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).cells_containing(4)
 10000 loops, best of 3: 81.5 us per loop
 }}}
 Before:
 {{{
 sage: %timeit
 Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).weight()
 10000 loops, best of 3: 190 us per loop
 }}}
 After:
 {{{
 sage: %timeit
 Tableau([[1,1,2,8,9],[2,5,6,11],[3,7,7,13],[4,8,9],[5],[13],[14]]).weight2()
 10000 loops, best of 3: 87.4 us per loop
 }}}

 Apply:

 * [attachment:trac_15269-tableau-speedup-dg.patch]
 * [attachment:trac_15269-review-ts.patch]

--

Comment:

 Hey Darij,

 Here's a small review patch which checks the old implementation agrees
 with the new one and some micro-optimizations where I was able to squeeze
 out a little bit more speed (on the order of 1%, but it's there). If
 you're happy with my changes, then go ahead and set a positive review.

 Best,[[BR]]
 Travis

--
Ticket URL: <http://trac.sagemath.org/ticket/15269#comment:2>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to