19 template <Automaton Aut>
32 const auto& ws = *res->context().weightset();
35 else if (!ws.is_one(w))
46 const auto& ws = *res->context().weightset();
49 else if (!ws.is_one(w))
52 for (
auto t:
all_out(res, initial))
69 template <
typename Tag = general_tag>
73 const auto& ws = *res->context().weightset();
76 else if (!ws.is_one(w))
105 res->set_initial(res->new_state());
116 template <Automaton Aut,
typename Tag = auto_tag>
124 template <Automaton Aut,
typename Tag = auto_tag>
127 -> fresh_automaton_t_of<Aut>
129 auto res =
copy(aut);
139 template <Automaton Aut,
typename Tag>
147 template <
typename WeightSet, Automaton Aut,
typename String>
150 const std::string& algo)
152 const auto& a1 = aut->
as<Aut>();
159 join(w1.valueset(), *a1->weightset()));
162 using automaton_t = decltype(a2);
163 auto w2 = ctx.weightset()->conv(w1.valueset(), w1.value());
164 using weight_t = decltype(w2);
165 static const auto map
168 "left-multiply algorithm",
170 {
"auto", lweight_tag<automaton_t, auto_tag>},
171 {
"general", lweight_tag<automaton_t, general_tag>},
172 {
"standard", lweight_tag<automaton_t, standard_tag>},
175 return map[algo](w2, a2);
184 template <
typename ValueSet>
188 const typename ValueSet::value_t&
r)
189 -> decltype(
rs.lweight(w,
r))
191 return rs.lweight(w,
r);
198 template <
typename WeightSet,
typename ExpSet>
199 expansionset<expressionset<context<labelset_t_of<ExpSet>,
200 join_t<WeightSet, weightset_t_of<ExpSet>>>>>
213 template <
typename WeightSet,
typename ExpansionSet>
218 const auto& r1 = exp->
as<ExpansionSet>();
221 = rs.expressionset().weightset()->conv(w1.valueset(), w1.value());
222 auto r2 = rs.conv(r1.valueset(), r1.value());
252 template <
typename WeightSet,
typename ExpSet>
253 expressionset<context<labelset_t_of<ExpSet>,
254 join_t<WeightSet, weightset_t_of<ExpSet>>>>
267 template <
typename WeightSet,
typename ExpSet>
272 const auto& r1 = exp->as<ExpSet>();
274 auto w2 = rs.weightset()->conv(w1.valueset(), w1.value());
275 auto r2 = rs.conv(r1.valueset(), r1.value());
285 template <
typename WeightSet,
typename ExpSet>
291 join(ws, *ps.weightset())));
299 template <
typename WeightSet,
typename PolynomialSet>
304 const auto& p1 = poly->
as<PolynomialSet>();
306 auto w2 = ps.weightset()->conv(w1.valueset(), w1.value());
307 auto p2 = ps.conv(p1.valueset(), p1.value());
319 template <Automaton Aut,
typename Tag = auto_tag>
327 template <Automaton Aut,
typename Tag = auto_tag>
328 fresh_automaton_t_of<Aut>
331 auto res =
copy(aut);
341 template <Automaton Aut,
typename Tag>
349 template <Automaton Aut,
typename WeightSet,
typename String>
352 const std::string& algo)
354 const auto& a1 = aut->
as<Aut>();
361 join(w1.valueset(), *a1->weightset()));
364 using automaton_t = decltype(a2);
365 auto w2 = ctx.weightset()->conv(w1.valueset(), w1.value());
366 using weight_t = decltype(w2);
367 static const auto map
370 "right-multiply algorithm",
372 {
"auto", rweight_tag<automaton_t, auto_tag>},
373 {
"general", rweight_tag<automaton_t, general_tag>},
374 {
"standard", rweight_tag<automaton_t, standard_tag>},
377 return map[algo](a2, w2);
386 template <
typename ValueSet>
387 typename ValueSet::value_t
389 const typename ValueSet::value_t&
r,
392 return rs.rweight(r, w);
404 template <
typename ExpansionSet,
typename WeightSet>
409 const auto& r1 = exp->
as<ExpansionSet>();
412 = rs.expressionset().weightset()->conv(w1.valueset(), w1.value());
413 auto r2 = rs.conv(r1.valueset(), r1.value());
428 template <
typename ExpSet,
typename WeightSet>
433 const auto& r1 = exp->as<ExpSet>();
435 auto w2 = rs.weightset()->conv(w1.valueset(), w1.value());
436 auto r2 = rs.conv(r1.valueset(), r1.value());
451 template <
typename PolynomialSet,
typename WeightSet>
456 const auto& p1 = poly->
as<PolynomialSet>();
458 auto w2 = ps.weightset()->conv(w1.valueset(), w1.value());
459 auto p2 = ps.conv(p1.valueset(), p1.value());
Tag for operations on all automata.
Aut & rweight_here(Aut &res, const weight_t_of< Aut > &w, Tag tag={})
In place right-multiplication of an automaton by a weight.
expressionset< context< labelset_t_of< ExpSet >, join_t< WeightSet, weightset_t_of< ExpSet > > > > join_weightset_expressionset(const WeightSet &ws, const ExpSet &rs)
Join between an expressionset and a weightset.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
Ctx make_context(const std::string &name)
Build a context from its name.
weightset_t_of< context_t > weightset_t
expansionset< expressionset< context< labelset_t_of< ExpSet >, join_t< WeightSet, weightset_t_of< ExpSet > > > > > join_weightset_expansionset(const WeightSet &ws, const expansionset< ExpSet > &rs)
state_t_of< automaton_t > state_t
context_t_of< automaton_t > context_t
Tag for operations on standard automata.
auto lweight(const ValueSet &rs, const weight_t_of< ValueSet > &w, const typename ValueSet::value_t &r) -> decltype(rs.lweight(w, r))
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
Tag to request the most appropriate version of an algorithm.
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
weight_t_of< context_t > weight_t
polynomial rweight_polynomial(const polynomial &poly, const weight &weight)
Bridge (rweight).
static automaton_t & lweight_here(const weight_t &w, automaton_t &res, auto_tag={})
Same as standard if res is standard, otherwise, general.
fresh_automaton_t_of< Aut > rweight(const Aut &aut, const weight_t_of< Aut > &w, Tag tag={})
Right-multiplication of an automaton by a weight.
automaton rweight_tag(Aut &aut, const weight_t_of< Aut > &w)
Right-product.
bool is_standard(const Aut &a)
Whether a is standard.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...
expression lweight_expression(const weight &weight, const expression &exp)
Bridge (lweight).
AutOut make_fresh_automaton(const AutIn &model)
Create an empty, mutable, automaton, based on another one.
static automaton_t & rweight_here(automaton_t &res, const weight_t &w, Tag tag={})
Right-multiplication of any automaton by a weight.
const expressionset_t & expressionset() const
The expressionset.
Implementation of left- and right- multiplication of an automaton by a weight.
static automaton_t & zero_here(automaton_t &res, general_tag)
Transform res into the empty automaton.
void copy_into(const AutIn &in, AutOut &out, KeepState keep_state, KeepTrans keep_trans)
Copy selected states and transitions of an automaton.
value_impl< detail::polynomial_tag > polynomial
automaton lweight_tag(const weight_t_of< Aut > &w, Aut &aut)
Left-product.
automaton lweight(const weight &weight, const automaton &aut, const std::string &algo)
Bridge.
auto lweight(const weight_t_of< Aut > &w, const Aut &aut, Tag tag={}) -> fresh_automaton_t_of< Aut >
Left-multiplication of an automaton by a weight.
context join(const context &c1, const context &c2)
Bridge.
auto join_weightset_polynomialset(const WeightSet &ws, const polynomialset< ExpSet > &ps)
static automaton_t & rweight_here(automaton_t &res, const weight_t &w, auto_tag={})
Same as standard if res is standard, otherwise, general.
value_impl< detail::expansion_tag > expansion
context make_context(const std::string &name)
Bridge.
automaton rweight(const automaton &aut, const weight &weight, const std::string &algo)
Bridge.
polynomial lweight_polynomial(const weight &weight, const polynomial &poly)
Bridge (lweight).
expression rweight_expression(const expression &exp, const weight &weight)
Bridge (rweight).
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
polynomialset< Context, Kind > make_polynomialset(const Context &context)
expansion rweight_expansion(const expansion &exp, const weight &weight)
Bridge (rweight).
Aut & lweight_here(const weight_t_of< Aut > &w, Aut &res, Tag tag={})
In place left-multiplication of an automaton by a weight.
auto & as()
Extract wrapped typed value.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto & as()
Extract wrapped typed automaton.
ValueSet::value_t rweight(const ValueSet &rs, const typename ValueSet::value_t &r, const weight_t_of< ValueSet > &w)
A mapping from strings to Values.
Provide a variadic mul on top of a binary mul(), and one().
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
static automaton_t & lweight_here(const weight_t &w, automaton_t &res, general_tag tag)
Left-multiplication of any automaton by a weight.
expansion lweight_expansion(const weight &weight, const expansion &exp)
Bridge (lweight).
static automaton_t & lweight_here(const weight_t &w, automaton_t &res, standard_tag tag)
Standard-preserving left-multiplication by a weight.
value_impl< detail::expression_tag > expression
Container::value_type front(const Container &container)
The first member of this Container.
auto final_transitions(const Aut &aut) -> decltype(aut->all_in(aut->post()))
Indexes of transitions from (visible) final states.
expansionset< ExpSet > make_expansionset(const ExpSet &expset)
static automaton_t & zero_here(automaton_t &res, standard_tag)
Transform res into the (standard) empty automaton.
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)