17 #ifndef AWALI_ALGOS_SUM_HH
18 # define AWALI_ALGOS_SUM_HH
39 template <
typename A,
typename B>
48 std::map<state_t, state_t> m;
49 state_t initial = res->dst_of(*(res->initial_transitions().begin()));
50 for (
auto s:
b->states())
51 m.emplace(s,
b->is_initial(s) ? initial : res->add_state());
52 m.emplace(
b->pre(), res->pre());
53 m.emplace(
b->post(), res->post());
56 for (
auto t:
b->all_transitions())
59 if (
b->src_of(t) !=
b->pre())
61 if (
b->dst_of(t) ==
b->post())
62 res->add_transition(m[
b->src_of(t)], m[
b->dst_of(t)],
63 b->label_of(t),
b->weight_of(t));
65 res->new_transition(m[
b->src_of(t)], m[
b->dst_of(t)],
66 b->label_of(t),
b->weight_of(t));
100 template <
typename Res,
typename Aut>
103 sum_here(Res& res,
const Aut& aut,
bool sum_standard=
false)
134 template <
typename Aut1,
typename Aut2>
137 sum(
const Aut1& aut1,
const Aut2& aut2,
bool sum_standard=
false)
151 template <
typename ValueSet>
153 typename ValueSet::value_t
155 const typename ValueSet::value_t& lhs,
156 const typename ValueSet::value_t& rhs)
158 return vs.add(lhs, rhs);
The Boolean semring.
Definition: b.hh:38
A & sum_of_standard_here(A &res, const B &b)
Merge transitions of b into those of res.
Definition: sum.hh:41
auto sum(const Aut1 &aut1, const Aut2 &aut2, bool sum_standard=false) -> decltype(join_automata(aut1, aut2))
sums two automata
Definition: sum.hh:137
bool is_standard(const Aut &a)
Definition: standard.hh:40
void copy_into(const AutIn &in, AutOut &out, Pred keep_state, bool keep_history=true, bool transpose=false)
Copy an automaton.
Definition: copy.hh:144
auto join_automata(Auts &&... auts) -> decltype(make_mutable_automaton(join(auts->context()...)))
Join between automata.
Definition: product.hh:39
Res & sum_here(Res &res, const Aut &aut, bool sum_standard=false)
Merge transitions of b into those of res.
Definition: sum.hh:103
void require(bool b, Args &&... args)
If b is not verified, raise an error with args as message.
Definition: raise.hh:55
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21