17 #ifndef VCSN_ALGORITHMS_ACI_CANONICAL_HXX
18 # define VCSN_ALGORITHMS_ACI_CANONICAL_HXX
22 # include <vaucanson/algebra/concept/series_base.hh>
23 # include <vaucanson/algebra/implementation/series/krat_exp_pattern.hh>
38 template <
class Series,
class T,
class Dispatch>
40 KRatExpAciCanonical<Series, T, Dispatch>,
42 std::set< Element<Series, T> >,
47 typedef std::set<exp_t> set_t;
48 typedef std::set<exp_t> return_type;
49 typedef typename set_t::iterator iterator_t;
52 typedef typename semiring_elt_t::value_t semiring_elt_value_t;
54 typedef typename monoid_elt_t::set_t monoid_t;
55 typedef typename monoid_t::alphabet_t alphabet_t;
56 typedef typename alphabet_t::letter_t letter_t;
57 INHERIT_CONSTRUCTORS(
self_t, T, semiring_elt_t, Dispatch);
65 set_t apply_sum(set_t expset)
67 if (expset.size() != 1)
69 iterator_t i = expset.begin();
71 for (i++; i != expset.end(); ++i)
81 set_t& put_in(set_t& s,
exp_t e)
89 exp_t set2exp(set_t expset)
91 expset = apply_sum(expset);
92 return *expset.begin();
96 MATCH__(Product, lhs, rhs)
98 set_t lset = apply_sum(this->
match(lhs));
99 set_t rset = apply_sum(this->
match(rhs));
100 put_in(lset, *lset.begin() * *rset.begin());
105 MATCH__(Sum, lhs, rhs)
107 set_t lset = this->
match(lhs);
108 set_t rset = this->
match(rhs);
110 merge(lset.begin(), lset.end(),
111 rset.begin(), rset.end(),
112 inserter(res, res.begin()));
119 set_t cset = apply_sum(this->
match(e));
120 exp_t exp = *cset.begin();
121 put_in(cset, exp.star());
126 MATCH__(LeftWeight, w, e)
128 set_t cset = apply_sum(this->
match(e));
129 put_in(cset, semiring_elt_t(w) * *cset.begin());
134 MATCH__(RightWeight, e, w)
136 set_t cset = apply_sum(this->
match(e));
137 put_in(cset, *cset.begin() * semiring_elt_t(w));
171 template <
typename S,
typename SI>
176 return matcher.set2exp(matcher.match(exp.
value()));
179 template <
typename S,
typename SI>
183 BENCH_TASK_SCOPED(
"canonical");
184 return do_canonical(exp.
structure(), exp);
189 #endif // ! VCSN_ALGORITHMS_ACI_CANONICAL_HXX