1 #ifndef VCSN_ALGOS_EXPAND_HH
2 # define VCSN_ALGOS_EXPAND_HH
21 template <
typename RatExpSet>
23 :
public RatExpSet::const_visitor
27 using ratexp_t =
typename ratexpset_t::value_t;
30 using weight_t =
typename weightset_t::value_t;
35 using super_t =
typename RatExpSet::const_visitor;
37 constexpr
static const char*
me() {
return "expand"; }
54 for (
const auto& m: p)
55 res =
rs_.add(res,
rs_.lmul(m.second, m.first));
86 res_ = std::move(res);
91 auto res =
expand(v.head());
92 for (
auto c: v.tail())
95 for (
const auto& l: res)
98 rs_.conjunction(l.first,
r.first),
99 ws_.mul(l.second,
r.second));
102 res_ = std::move(res);
115 res_ = std::move(res);
121 v.sub()->accept(*
this);
127 v.sub()->accept(*
this);
133 v.sub()->accept(*
this);
150 template <
typename RatExpSet>
151 typename RatExpSet::value_t
152 expand(
const RatExpSet& rs,
const typename RatExpSet::value_t& e)
163 template <
typename RatExpSet>
167 const auto& e = exp->as<RatExpSet>();
178 #endif // !VCSN_ALGOS_EXPAND_HH
Linear combination of labels: map labels to weights.
ratexp make_ratexp(const RatExpSet &rs, const typename RatExpSet::value_t &ratexp)
typename weightset_t::value_t weight_t
expand_visitor(const ratexpset_t &rs)
value_t & add_here(value_t &v, const value_t &p) const
v += p.
An inner node with multiple children.
#define VCSN_RAT_UNSUPPORTED(Type)
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
ratexp_t ratexp(const polynomial_t p)
static constexpr const char * me()
ratexp_polynomialset_t< RatExpSet > make_ratexp_polynomialset(const RatExpSet &rs)
From a RatExpSet to its polynomialset.
typename ratexpset_t::value_t ratexp_t
weightset_t ws_
Shorthand to the weightset.
weightset_t_of< ratexpset_t > weightset_t
value_t rmul(const value_t &v, const weight_t &w) const
Right exterior product.
const value_t & zero() const
RatExpSet::value_t expand(const RatExpSet &rs, const typename RatExpSet::value_t &e)
Expanding a typed ratexp shared_ptr.
std::shared_ptr< detail::ratexp_base > ratexp
value_t lmul(const weight_t &w, const value_t &v) const
Left exterior product.
value_t mul(const value_t &l, const value_t &r) const
The product of polynomials l and r.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename polynomialset_t::value_t polynomial_t
polynomial_t res_
The result.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
polynomialset_t ps_
Polynomialset of ratexps.
VCSN_RAT_VISIT(rweight, v)
value_t add(const value_t &l, const value_t &r) const
The sum of polynomials l and r.
ratexp expand(const ratexp &exp)
Bridge.
context_t_of< ratexpset_t > context_t
Provide a variadic mul on top of a binary mul(), and one().
An inner node implementing a weight.
std::map< label_t, weight_t, vcsn::less< labelset_t >> value_t
VCSN_RAT_VISIT(conjunction, v)
polynomial_t expand(const ratexp_t &e)
Syntactic sugar: recursive call to this visitor.
const value_t & one() const
typename RatExpSet::const_visitor super_t
VCSN_RAT_VISIT(lweight, v)
ratexp_t operator()(const ratexp_t &v)