17 #ifndef VCSN_ALGORITHMS_CUT_UP_HXX
18 # define VCSN_ALGORITHMS_CUT_UP_HXX
36 template <
typename A,
typename AI>
39 BENCH_TASK_SCOPED(
"is_cut_up");
41 AUTOMATON_TYPES(automaton_t);
43 for_all_const_transitions(e, a)
44 if (! a.series_of(*e).is_finite_app() ||
45 a.series_of(*e).supp().size() > 1)
56 template <
typename S,
typename T,
typename TT,
typename Auto,
typename Ret>
57 void do_cut_up(
const AutomataBase<S>&,
58 const rat::exp<T, TT>&,
62 AUTOMATON_TYPES_(Ret, ret_);
63 typedef typename generalized_traits<Ret>::automaton_t gen_automaton_t;
64 AUTOMATON_TYPES(gen_automaton_t);
68 std::map<hstate_t, ret_hstate_t> statemap;
70 ret_transitions_t transitions = res.transitions();
72 for_all_(ret_transitions_t, e, transitions)
74 if (! res.series_of(*e).is_finite_app() ||
75 res.series_of(*e).supp().size() > 1)
77 gen_automaton_t tmp(res.structure());
80 for_all_states(s, tmp)
81 statemap[*s] = res.add_state();
83 for_all_initial_states(i, tmp)
84 res.add_series_transition(res.src_of(*e),
88 for_all_transitions(ed, tmp)
89 res.add_transition(statemap[tmp.src_of(*ed)],
90 statemap[tmp.dst_of(*ed)],
93 for_all_final_states(f, tmp)
94 res.add_series_transition(statemap[*f], res.dst_of(*e),
97 res.del_transition(*e);
107 template <typename S, typename T, typename TT, typename Auto, typename Ret>
108 void do_cut_up(const S&,
109 const algebra::polynom<T, TT>&,
113 AUTOMATON_TYPES(Ret);
114 typedef typename Ret::series_set_elt_t::support_t support_t;
119 transitions_t transitions = res.transitions();
121 for_all_(transitions_t, e, transitions)
123 series_set_elt_t label(res.structure().series());
124 label = res.series_of(*e);
126 if ((size = label.supp().size()) > 1)
128 typename support_t::const_iterator m = label.supp().begin();
129 for (
int i = 0; i < size; ++i, ++m)
131 series_set_elt_t series(res.structure().series());
132 series.assoc(*m, label.get(*m));
133 res.add_series_transition(res.src_of(*e),
138 res.del_transition(*e);
148 template <
typename A,
typename AI>
152 BENCH_TASK_SCOPED(
"cut_up");
158 template <
typename A,
typename AI>
168 template <
typename A,
typename AI>
179 #endif // ! VCSN_ALGORITHMS_CUT_UP_HXX