1 #ifndef VCSN_ALGOS_STAR_HH
2 # define VCSN_ALGOS_STAR_HH
19 template <
typename Aut>
25 using automaton_t = Aut;
31 weightset_t ws(*res->context().weightset());
33 state_t initial = res->dst_of(res->initial_transitions().front());
35 weight_t w = ws.star(res->get_final_weight(initial));
38 for (
auto ti: res->out(initial))
40 res->lmul_weight(ti, w);
41 for (
auto tf: res->final_transitions())
42 if (res->src_of(tf) != initial)
49 ws.mul(res->weight_of(tf), res->weight_of(ti)));
51 for (
auto tf: res->final_transitions())
52 res->rmul_weight(tf, w);
53 res->set_final(initial, w);
59 template <
typename Aut>
60 typename Aut::element_type::automaton_nocv_t
73 template <
typename Aut>
77 const auto& aut = a->as<Aut>();
87 #endif // !VCSN_ALGOS_STAR_HH
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
bool is_standard(const Aut &a)
Whether a is standard.
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
automaton star(const automaton &a)
Bridge.
AutOut copy(const AutIn &input, Pred keep_state)
A copy of input keeping only its states that are accepted by keep_state.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
Aut & star_here(Aut &res)
In place star of a standard automaton.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
Aut::element_type::automaton_nocv_t star(const Aut &aut)
Star of a standard automaton.
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.