1 #ifndef VCSN_ALGOS_DIVKBASEB_HH
2 # define VCSN_ALGOS_DIVKBASEB_HH
16 template <
typename Context>
17 mutable_automaton<Context>
18 divkbaseb(
const Context& ctx,
unsigned divisor,
unsigned base)
20 using context_t = Context;
23 const auto& gens = ctx.labelset()->genset();
24 std::vector<typename context_t::labelset_t::letter_t> letters
25 {std::begin(gens), std::end(gens)};
28 "divkbaseb: divisor cannot be 0");
31 +
") must be at least 2");
34 +
") must be less than or equal to the alphabet size ("
37 automaton_t res = make_shared_ptr<automaton_t>(ctx);
43 std::vector<state_t> states;
44 for (
unsigned i = 0; i < divisor; ++i)
45 states.emplace_back(res->new_state());
47 res->set_initial(states[0]);
48 res->set_final(states[0]);
50 for (
unsigned i = 0; i < divisor; ++i)
53 for (
unsigned l = 0; l < base; ++l)
55 int d = (e + l) % divisor;
56 res->new_transition(states[i], states[d], letters[l]);
68 template <
typename Ctx,
typename Un
signed1,
typename Un
signed2>
72 const auto& c = ctx->as<Ctx>();
84 #endif // !VCSN_ALGOS_DIVKBASEB_HH
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
std::string to_string(identities i)
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
automaton divkbaseb(const context &ctx, unsigned divisor, unsigned base)
Bridge.
Provide a variadic mul on top of a binary mul(), and one().
std::shared_ptr< const detail::context_base > context
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...
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.