21 template <Automaton Aut>
25 const auto& ws = *res->weightset();
26 const auto& ls = *res->labelset();
28 auto initial = res->new_state();
31 res->new_transition(initial, res->dst_of(ti),
32 ls.one(), res->weight_of(ti));
33 res->del_transition(ti);
37 res->add_transition(res->src_of(tf), initial,
38 ls.one(), res->weight_of(tf));
39 res->del_transition(tf);
41 res->set_initial(initial, ws.one());
42 res->set_final(initial, ws.one());
49 template <Automaton Aut>
59 using automaton_t = Aut;
65 weightset_t ws(*res->context().weightset());
69 weight_t w = ws.star(res->get_final_weight(initial));
72 for (
auto ti:
out(res, initial))
76 if (res->src_of(tf) != initial)
83 ws.mul(res->weight_of(tf), res->weight_of(ti)));
87 res->set_final(initial, w);
92 template <Automaton Aut>
106 template <Automaton Aut,
typename Tag = general_tag>
108 star(
const Aut& aut, Tag tag = {})
122 template <Automaton Aut,
typename String>
126 const auto& aut = a->
as<Aut>();
Tag for operations on all automata.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
Tag for operations on standard automata.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
bool is_standard(const Aut &a)
Whether a is standard.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
Aut & star_here(Aut &res, general_tag={})
In-place star of an automaton.
void standard_here(Aut &aut)
Turn aut into a standard automaton.
void copy_into(const AutIn &in, AutOut &out, KeepState keep_state, KeepTrans keep_trans)
Copy selected states and transitions of an automaton.
auto determinize(const Aut &a, Tag={}, bool_constant< Lazy >={})
auto make_join_automaton(deterministic_tag, Auts &&...auts) -> decltype(join_automata(std::forward< Auts >(auts)...))
Make an empty automaton which is a supertype of others.
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto dispatch_tags(std::string algo, Operation op, Aut &&...auts)
Dispatch an operation between automata depending on their nature.
auto & as()
Extract wrapped typed automaton.
Tag for operations on deterministic automata.
Container::value_type front(const Container &container)
The first member of this Container.
auto final_transitions(const Aut &aut) -> decltype(aut->all_in(aut->post()))
Indexes of transitions from (visible) final states.
auto star(const Aut &aut, Tag tag={}) -> decltype(detail::make_join_automaton(tag, aut))
Star of an automaton.
automaton star(const automaton &a, const std::string &algo)
Bridge.