16 template <
typename Context>
17 mutable_automaton<Context>
20 using context_t = Context;
23 const auto& ls = *ctx.labelset();
24 const auto& gens = ls.generators();
25 std::vector<label_t_of<context_t>> letters;
27 letters.emplace_back(ls.value(l));
30 "divkbaseb: divisor cannot be 0");
32 "divkbaseb: base (", base,
") must be at least 2");
34 "divkbaseb: base (", base,
35 ") must be less than or equal to the alphabet size (",
38 automaton_t res = make_shared_ptr<automaton_t>(
ctx);
44 std::vector<state_t> states;
45 for (
unsigned i = 0; i < divisor; ++i)
46 states.emplace_back(res->new_state());
48 res->set_initial(states[0]);
49 res->set_final(states[0]);
51 for (
unsigned i = 0; i < divisor; ++i)
54 for (
unsigned l = 0; l < base; ++l)
56 int d = (e + l) % divisor;
57 res->new_transition(states[i], states[d], letters[l]);
69 template <
typename Ctx,
typename Un
signed1,
typename Un
signed2>
73 const auto& c = ctx->as<Ctx>();
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
std::shared_ptr< const detail::context_base > context
A dyn::context.
std::shared_ptr< detail::automaton_base > automaton
automaton divkbaseb(const context &ctx, unsigned divisor, unsigned base)
Bridge.
static dyn::context ctx(const driver &d)
Get the context of the driver.
mutable_automaton< Context > divkbaseb(const Context &ctx, unsigned divisor, unsigned base)
Build the Boolean automaton which accepts a word n representing a number in base "base" if and only i...