#8227: Improving iterated palindromic closure computation
-----------------------------+----------------------------------------------
   Reporter:  abmasse        |       Owner:  abmasse                     
       Type:  enhancement    |      Status:  needs_work                  
   Priority:  major          |   Milestone:  sage-4.3.3                  
  Component:  combinatorics  |    Keywords:  iterated palindromic closure
     Author:  abmasse        |    Upstream:  N/A                         
   Reviewer:                 |      Merged:                              
Work_issues:                 |  
-----------------------------+----------------------------------------------
Description changed by abmasse:

Old description:

> There is a faster way to compute the iterated paindromic closure of a
> word than using the definition. The problem with the latter is that it
> needs to compute the longest f-palindromic suffix of the current word at
> each step, while it is possible to easily deduce this length only by
> looking at the directive word.[[BR]]
> Here is an example:
> {{{
> sage: w = words.RandomWord(10)
> sage: w.iterated_right_palindromic_closure(algorithm='definition')
> word: 0010010001001000100100010010001001001000...
> sage: timeit("print
> w.iterated_right_palindromic_closure(algorithm='definition').length()")
> 5 loops, best of 3: 211 ms per loop
> sage: timeit("print
> w.iterated_right_palindromic_closure(algorithm='recursive').length()")
> 25 loops, best of 3: 9.46 ms per loop
> }}}
> The difference is particularly notable for longer words:
> {{{
> sage: w = words.RandomWord(15)
> sage: timeit("print
> w.iterated_right_palindromic_closure(algorithm='definition').length()")
> 5 loops, best of 3: 3.73 s per loop
> sage: timeit("print
> w.iterated_right_palindromic_closure(algorithm='recursive').length()")
> 25 loops, best of 3: 37.4 ms per loop
> }}}

New description:

 There is a faster way to compute the iterated palindromic closure of a
 word than using the definition. The problem with the latter is that it
 needs to compute the longest f-palindromic suffix of the current word at
 each step, while it is possible to easily deduce this length only by
 looking at the directive word.[[BR]]
 Here is an example:
 {{{
 sage: w = words.RandomWord(10)
 sage: w.iterated_right_palindromic_closure(algorithm='definition')
 word: 0010010001001000100100010010001001001000...
 sage: timeit("print
 w.iterated_right_palindromic_closure(algorithm='definition').length()")
 5 loops, best of 3: 211 ms per loop
 sage: timeit("print
 w.iterated_right_palindromic_closure(algorithm='recursive').length()")
 25 loops, best of 3: 9.46 ms per loop
 }}}
 The difference is particularly notable for longer words:
 {{{
 sage: w = words.RandomWord(15)
 sage: timeit("print
 w.iterated_right_palindromic_closure(algorithm='definition').length()")
 5 loops, best of 3: 3.73 s per loop
 sage: timeit("print
 w.iterated_right_palindromic_closure(algorithm='recursive').length()")
 25 loops, best of 3: 37.4 ms per loop
 }}}

--

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