15 template <
typename Context>
16 mutable_automaton<Context>
20 using context_t = Context;
23 const auto& ls = *ctx.labelset();
24 const auto& gens = ls.generators();
29 "quotkbaseb: divisor cannot be 0");
31 "quotkbaseb: base (", base,
") must be at least 2");
33 "quotkbaseb: base (", base,
34 ") must be less than or equal to the left alphabet size (",
37 "quotkbaseb: base (", base,
38 ") must be less than or equal to the right alphabet size (",
41 automaton_t
res = make_shared_ptr<automaton_t>(
ctx);
47 std::vector<state_t> states;
48 for (
unsigned i = 0; i < divisor; ++i)
49 states.emplace_back(res->new_state());
51 res->set_initial(states[0]);
52 res->set_final(states[0]);
54 for (
unsigned i = 0; i < divisor; ++i)
57 for (
unsigned l = 0; l < base; ++l)
59 int d = (e + l) % divisor;
60 int f = (e + l) / divisor;
61 res->new_transition(states[i], states[d],
62 ls.tuple(lgens[l], rgens[f]));
74 template <
typename Ctx,
typename Un
signed1,
typename Un
signed2>
78 const auto& c = ctx->
as<Ctx>();
mutable_automaton< Context > quotkbaseb(const Context &ctx, unsigned divisor, unsigned base)
Build the transducer which accepts a word n representing a number in base "base" and outputs the quot...
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
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.
auto & as()
Downcast to the exact type.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
Template-less root for contexts.
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
automaton quotkbaseb(const context &ctx, unsigned divisor, unsigned base)
Bridge.