10.07.2015 Views

here - Sites personnels de TELECOM ParisTech - Télécom ParisTech

here - Sites personnels de TELECOM ParisTech - Télécom ParisTech

here - Sites personnels de TELECOM ParisTech - Télécom ParisTech

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.9. Efficient test of the Tu–Deng conjecture 89The usual representative of a necklace is its smallest element for lexicographic or<strong>de</strong>r. Wei<strong>de</strong>ntify equivalence classes and such elements.An efficient iterative algorithm for the generation of necklaces has been given in the works ofFredricksen and Maiorana [100] and Fredricksen and Kessler [99]. A slight variation of it wasproposed in<strong>de</strong>pen<strong>de</strong>ntly by Duval [77]. These algorithms have been respectively analyzed byRuskey, Savage and Wang [225] and Berstel and Pocchiola [14]. An overview of this problem anda recursive version of the original algorithm can also be found in the monograph of Ruskey [224,Subsection 7.2]. Algorithm 2.2 <strong>de</strong>scribes a slight variation of the building block of the iterativeversion as it can be found in Ruskey’s monograph [224, Algorithm 7.2]. It takes as input anystring and returns the smallest necklace strictly greater than it, together with the largest lengthsuch that a prefix of the necklace is a Lyndon word.Algorithm 2.2: Iterative generation of necklacesInput: A string word of length n on the alphabet {0, . . . , k − 1}Output: The smallest necklace strictly greater than word1 while True do2 p = n3 while word[p] == k-1 do4 p -= p-15 if p == 0 then6 return (∅, 0)7 word[p] += 18 for i = 1 to n − p do9 word[i+p] = word[i]10 if n ≡ 0 (mod p) then11 return (word, p)12 return True2.9.3 Implementation <strong>de</strong>tailsWe implemented Algorithm 2.1 in C [148] using version 2.2 of the FLINT library [127] forpolynomial and matrix arithmetic and version 1.5.4 of OpenMPI [106] to distribute computations.Our source co<strong>de</strong> was compiled using version 4.6.1 of GCC [265]. Algorithm 2.2 was used to buildthe numbers to test. It is in<strong>de</strong>ed particularly convenient to use that variation of the classicalalgorithms to distribute computations among different processes. Moreover, the knowledge of thelargest length such that a prefix of a necklace is a Lyndon word allows to reduce the number ofoperations for periodic necklaces: the matrix corresponding to the Lyndon word is computed andthen exponentiated to obtain the matrix corresponding to the necklace. Finally, the matricespowers B i and C i for 1 ≤ i ≤ k − 1 should be precomputed before looping over the necklaces.Furthermore, an easy induction shows that these matrices can be written as⎛⎛⎞1 P i (x) 1 P i (x)B i = ⎜0 2 i−1 x i 0 2 i−1 x i⎟⎝0 2 i−1 x i 0 2 i−1 x i ⎠ , Ci =0 2 i−1 x i 0 2 i−1 x iw<strong>here</strong> P i (x) = ∑ i−2j=0 2j x j+1 and Q i (x) = ∑ i−2j=0 2i−2−j x j+1 .⎜⎝⎞2 i−1 0 2 i−1 02 i−1 0 2 i−1 0⎟2 i−1 0 2 i−1 0 ⎠ ,Q i (x) x i Q i (x) x i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!