#15820: Improve efficiency of the path semigroup
--------------------------------------------------+------------------------
       Reporter:  SimonKing                       |        Owner:
           Type:  enhancement                     |       Status:  new
       Priority:  major                           |    Milestone:  sage-6.2
      Component:  algebra                         |   Resolution:
       Keywords:  quiver path algebra efficiency  |    Merged in:
        Authors:                                  |    Reviewers:
Report Upstream:  N/A                             |  Work issues:
         Branch:                                  |       Commit:
   Dependencies:  #12630                          |     Stopgaps:
--------------------------------------------------+------------------------

Comment (by SimonKing):

 I couldn't directly use `sage/misc/bitset`, but I could learn from it: I
 have improved the `Path_v4` implementation (here, the arrows will be
 encoded by chunks of memory whose size is a power of 2). This was possible
 by using `memcmp` in some place (not in the method `startswith()`, where a
 loop over the data is faster than memcmp) and, in particular, use bitshift
 operations to replace multiplications and integer divisions (this is only
 possible with `Path_v4`, since here the factors are powers of 2 and can
 thus correspond to shifts).

 New timings with `Path=Path_v4` and `SizeManager.set_edge_number(27)`:
 {{{
 sage: %timeit p5*q5
 1000000 loops, best of 3: 684 ns per loop
 sage: %timeit p5*q25
 1000000 loops, best of 3: 726 ns per loop
 sage: %timeit p25*q25
 1000000 loops, best of 3: 798 ns per loop
 sage: %timeit p25*q50
 1000000 loops, best of 3: 862 ns per loop
 sage: %timeit p50*q50
 1000000 loops, best of 3: 827 ns per loop
 sage: %timeit p50*q100
 1000000 loops, best of 3: 924 ns per loop
 sage: %timeit p100*q100
 1000000 loops, best of 3: 915 ns per loop
 sage: %timeit p100*q1000
 1000000 loops, best of 3: 1.91 us per loop
 sage: %timeit p1000*q1000
 1000000 loops, best of 3: 1.42 us per loop
 sage: %timeit hash(p5)
 10000000 loops, best of 3: 148 ns per loop
 sage: %timeit hash(p25)
 10000000 loops, best of 3: 158 ns per loop
 sage: %timeit hash(p50)
 10000000 loops, best of 3: 171 ns per loop
 sage: %timeit hash(p100)
 10000000 loops, best of 3: 194 ns per loop
 sage: %timeit hash(p1000)
 1000000 loops, best of 3: 594 ns per loop
 sage: %timeit p5==s5
 1000000 loops, best of 3: 498 ns per loop
 sage: %timeit p25==s25
 1000000 loops, best of 3: 547 ns per loop
 sage: %timeit p50==s50
 1000000 loops, best of 3: 631 ns per loop
 sage: %timeit p100==s100
 1000000 loops, best of 3: 712 ns per loop
 sage: %timeit p1000==s1000
 100000 loops, best of 3: 2.42 us per loop
 sage: %timeit p5==r5
 1000000 loops, best of 3: 499 ns per loop
 sage: %timeit p25==r25
 1000000 loops, best of 3: 514 ns per loop
 sage: %timeit p50==r50
 1000000 loops, best of 3: 549 ns per loop
 sage: %timeit p100==r100
 1000000 loops, best of 3: 526 ns per loop
 sage: %timeit p1000==r1000
 1000000 loops, best of 3: 545 ns per loop
 sage: %timeit q5==r5
 1000000 loops, best of 3: 506 ns per loop
 sage: %timeit q25==r25
 1000000 loops, best of 3: 544 ns per loop
 sage: %timeit q50==r50
 1000000 loops, best of 3: 589 ns per loop
 sage: %timeit q100==r100
 1000000 loops, best of 3: 704 ns per loop
 sage: %timeit q1000==r1000
 100000 loops, best of 3: 2.48 us per loop
 sage: %timeit q1000.startswith(q100)
 1000000 loops, best of 3: 263 ns per loop
 sage: %timeit q1000.startswith(r100)
 1000000 loops, best of 3: 232 ns per loop
 }}}

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