1 #ifndef VCSN_ALGOS_SUM_HH
2 # define VCSN_ALGOS_SUM_HH
26 template <
typename A,
typename B>
35 state_t_of<A> initial = res->dst_of(res->initial_transitions().front());
36 for (
auto s: b->states())
37 m.emplace(s, b->is_initial(s) ? initial : res->new_state());
38 m.emplace(b->pre(), res->pre());
39 m.emplace(b->post(), res->post());
42 for (
auto t: b->all_transitions())
45 if (b->src_of(t) != b->pre())
47 if (b->dst_of(t) == b->post())
48 res->add_transition(m[b->src_of(t)], m[b->dst_of(t)],
50 res->weightset()->conv(*b->weightset(),
53 res->new_transition(m[b->src_of(t)], m[b->dst_of(t)],
55 res->weightset()->conv(*b->weightset(),
62 template <
typename A,
typename B>
65 sum(
const A& lhs,
const B& rhs)
70 res->set_initial(res->new_state());
81 template <
typename Lhs,
typename Rhs>
85 const auto& l = lhs->as<Lhs>();
86 const auto&
r = rhs->as<Rhs>();
101 template <
typename ValueSet>
103 typename ValueSet::value_t
105 const typename ValueSet::value_t& lhs,
106 const typename ValueSet::value_t& rhs)
108 return vs.add(lhs, rhs);
117 template <
typename PolynomialSetLhs,
typename PolynomialSetRhs>
121 const auto& l = lhs->as<PolynomialSetLhs>();
122 const auto&
r = rhs->as<PolynomialSetRhs>();
123 auto rs =
join(l.polynomialset(), r.polynomialset());
124 auto lr = rs.conv(l.polynomialset(), l.polynomial());
125 auto rr = rs.conv(r.polynomialset(), r.polynomial());
144 template <
typename RatExpSetLhs,
typename RatExpSetRhs>
148 const auto& l = lhs->as<RatExpSetLhs>();
149 const auto&
r = rhs->as<RatExpSetRhs>();
150 auto rs =
join(l.ratexpset(), r.ratexpset());
151 auto lr = rs.conv(l.ratexpset(), l.ratexp());
152 auto rr = rs.conv(r.ratexpset(), r.ratexp());
171 template <
typename WeightSetLhs,
typename WeightSetRhs>
175 const auto& l = lhs->as<WeightSetLhs>();
176 const auto&
r = rhs->as<WeightSetRhs>();
177 auto rs =
join(l.weightset(), r.weightset());
178 auto lr = rs.conv(l.weightset(), l.weight());
179 auto rr = rs.conv(r.weightset(), r.weight());
189 #endif // !VCSN_ALGOS_SUM_HH
ratexp make_ratexp(const RatExpSet &rs, const typename RatExpSet::value_t &ratexp)
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
automaton sum(const automaton &lhs, const automaton &rhs)
Bridge.
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &polynomial)
bool is_standard(const Aut &a)
Whether a is standard.
polynomial sum_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge.
std::shared_ptr< const detail::weight_base > weight
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::ratexp_base > ratexp
auto join_automata(Auts &&...auts) -> decltype(make_mutable_automaton(join(auts->context()...)))
Join between automata.
weight sum_weight(const weight &lhs, const weight &rhs)
Bridge.
A & sum_here(A &res, const B &b)
Merge transitions of b into those of res.
weight make_weight(const WeightSet &ws, const typename WeightSet::value_t &w)
Provide a variadic mul on top of a binary mul(), and one().
auto sum(const A &lhs, const B &rhs) -> decltype(join_automata(lhs, rhs))
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
std::shared_ptr< const detail::polynomial_base > polynomial
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
ratexp sum_ratexp(const ratexp &lhs, const ratexp &rhs)
Bridge.