33#include "DGtal/base/Common.h"
34#include "DGtal/base/OrderedAlphabet.h"
52 const string & output,
61 unsigned int e = (
unsigned int)w1.size();
65 s1 <<
"(" << w1.substr( s, len ) <<
")^" << nb;
71 trace.
info() <<
" input = " << input << endl;
72 trace.
info() <<
"expected = " << output << endl;
73 trace.
info() <<
"computed = " << s1.str() << endl;
76 return s1.str() == a1;
89 const string & output,
97 s1 <<
"C(" << input.substr( 0, len ) <<
")^" << nb;
98 else s1 <<
"NC(" << len <<
")";
101 trace.
info() <<
" input = " << input << endl;
102 trace.
info() <<
"expected = " << output << endl;
103 trace.
info() <<
"computed = " << s1.str() << endl;
106 return s1.str() == output;
120 const string & output,
121 const string & input,
126 bool christoffel = alphabet.
duvalPPMod( len, nb, input, s, s );
131 for (
unsigned int i = 0; i < len; ++i )
134 s = s + 1 % input.size();
138 else s1 <<
"NC(" << len <<
")";
141 trace.
info() <<
" input = " << input << endl;
142 trace.
info() <<
"expected = " << output << endl;
143 trace.
info() <<
"computed = " << s1.str() << endl;
146 return s1.str() == output;
156 unsigned int nb_ok = 0;
157 unsigned int nb_ko = 0;
159 string w1 =
"01101010100101001010001";
160 string a1=
"(011)^1(01)^3(00101)^2(0001)^1";
161 if (
testFLF( A, a1, w1 ) ) nb_ok++;
163 w1 =
"01232112232232103220123210120";
164 a1 =
"(0123211223223210322)^1(012321)^1(012)^1(0)^1";
165 if (
testFLF( A, a1, w1 ) ) nb_ok++;
167 w1 =
"1112111211211121121112111211211121121111";
168 a1 =
"C(111211121121112112)^2";
171 w1 =
"1112111211211121121121111211211121121111";
175 w1 =
"2111211211121121111111211121121112112111";
176 a1 =
"C(111211121121112112)^2";
180 trace.
info() <<
"Tests passed: " << nb_ok <<
"/"
181 << ( nb_ok + nb_ko ) << endl;
188int main(
int argc,
char** argv )
192 for (
int i = 0; i < argc; ++i )
197 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Describes an alphabet over an interval of (ascii) letters, where the lexicographic order can be ...
bool duvalPP(size_t &len, size_t &nb, const std::string &w, index_t s, index_t e) const
void firstLyndonFactor(size_t &len, size_t &nb, const std::string &w, index_t s, index_t e) const
bool duvalPPMod(size_t &len, size_t &nb, const std::string &w, index_t s, index_t e) const
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
bool testOrderedAlphabet()
bool testFLF(const OrderedAlphabet &alphabet, const string &output, const string &input)
bool testDuvalPP(const OrderedAlphabet &alphabet, const string &output, const string &input)
bool testDuvalPPMod(const OrderedAlphabet &alphabet, const string &output, const string &input, OrderedAlphabet::index_t s)