1 #ifndef VCSN_ALGOS_DOUBLE_RING_HH
2 # define VCSN_ALGOS_DOUBLE_RING_HH
15 template <
class Context>
16 mutable_automaton<Context>
18 const std::vector<unsigned>& finals)
20 using context_t = Context;
21 const auto& gens = ctx.labelset()->genset();
22 std::vector<typename context_t::labelset_t::letter_t> letters
23 {std::begin(gens), std::end(gens)};
25 "double_ring: the alphabet needs at least 2 letters");
31 automaton_t res = make_shared_ptr<automaton_t>(ctx);
36 auto p = res->new_state();
39 std::map<unsigned, state_t> states;
44 for (
unsigned i = 1; i < n; ++i)
46 state_t y = res->new_state();
47 res->new_transition(x, y, a);
48 res->new_transition(y, x,
b);
52 res->new_transition(x, p, a);
53 res->new_transition(p, x,
b);
58 require(f < n,
"double_ring: invalid list of finals");
59 res->set_final(states[f]);
74 template <
typename Ctx,
typename,
typename>
77 const std::vector<unsigned>& f)
79 const auto& c = ctx->as<Ctx>();
84 (
const context& ctx,
unsigned n,
85 const std::vector<unsigned>& f) ->
automaton);
90 #endif // !VCSN_ALGOS_DOUBLE_RING_HH
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
mutable_automaton< Context > double_ring(const Context &ctx, unsigned n, const std::vector< unsigned > &finals)
Provide a variadic mul on top of a binary mul(), and one().
std::shared_ptr< const detail::context_base > context
automaton double_ring(const dyn::context &ctx, unsigned n, const std::vector< unsigned > &f)
Bridge.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.