#19322: a much faster longest_common_prefix for words
-----------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.9
Component: combinatorics | Keywords:
Merged in: | Authors: Vincent Delecroix
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
-----------------------------+-------------------------------------
I had to do some computations of the following kind... which are damn slow
{{{
sage: w = words.FibonacciWord()[:10000]
sage: %time L = [[len(w[n:].longest_common_prefix(w[n+fibonacci(i):])) for
i in range(5,20)] for n in range(1,1000)]
CPU times: user 20.6 s, sys: 44 ms, total: 20.7 s
Wall time: 20.5 s
sage: w = Words([0,1])(list(words.FibonacciWord()[:10000]))
sage: %time L = [[len(w[n:].longest_common_prefix(w[n+fibonacci(i):])) for
i in range(5,20)] for n in range(1,1000)]
CPU times: user 7.99 s, sys: 56 ms, total: 8.04 s
Wall time: 7.93 s
}}}
and with the branch
{{{
sage: w = Words([0,1])(list(words.FibonacciWord()[:10000]))
sage: %time L = [[len(w[n:].longest_common_prefix(w[n+fibonacci(i):])) for
i in range(5,20)] for n in range(1,1000)]
CPU times: user 172 ms, sys: 0 ns, total: 172 ms
Wall time: 168 ms
}}}
We also implement `longest_common_suffix` and fix the following annoying
feature of `has_prefix`
{{{
sage: W = Words([0,1,2])
sage: w = W([0,1,0,2])
sage: w.has_prefix(words.FibonacciWord())
False
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/19322>
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/d/optout.