17 #ifndef AWALI_ALGOS_STAR_HH
18 # define AWALI_ALGOS_STAR_HH
38 template<
typename Aut,
typename P>
42 const auto& ws=*res->context().weightset();
48 state_t initial = res->dst_of(*(res->initial_transitions().begin()));
50 auto w = ws.star(res->get_final_weight(initial));
53 for (
auto ti: res->out(initial))
55 res->lmul_weight(ti, w);
56 for (
auto tf: res->final_transitions())
57 if (res->src_of(tf) != initial)
64 ws.mul(res->weight_of(tf), res->weight_of(ti)));
66 for (
auto tf: res->final_transitions())
67 res->rmul_weight(tf, w);
68 res->set_final(initial, w);
72 template<
typename Aut,
typename P>
76 const auto& ws=*res->weightset();
77 auto one=res->labelset()->one();
78 for (
auto ft: res->final_transitions())
79 for (
auto it: res->initial_transitions())
80 res->add_transition(res->src_of(ft),
83 ws.mul(res->weight_of(ft), res->weight_of(it)));
85 res->set_initial(init);
91 template<
typename Aut>
98 template <
typename Aut>
99 typename Aut::element_type::automaton_nocv_t
102 auto res =
copy(aut);
static constexpr TOP< void > value
Definition: priority.hh:93
Definition: priority.hh:52
Aut & star_here(Aut &res, priority::ONE< P >)
In place star of an automaton.
Definition: star.hh:40
Aut::element_type::automaton_nocv_t star(const Aut &aut)
Star of an automaton.
Definition: star.hh:100
AutOut copy(const AutIn &input, Pred keep_state, bool keep_history=true, bool transpose=false)
A copy of input keeping only its states that are accepted by keep_state.
Definition: copy.hh:189
void standard_here(Aut &aut)
Turn aut into a standard automaton.
Definition: standard.hh:58
Aut & star_here(Aut &res)
Definition: star.hh:93
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21