1 #ifndef VCSN_ALGOS_SPLIT_HH
2 # define VCSN_ALGOS_SPLIT_HH
20 template <
typename RatExpSet>
22 = polynomialset<
context<RatExpSet,
26 template <
typename RatExpSet>
31 template <
typename RatExpSet>
36 using context_t =
context<RatExpSet,
77 template <
typename RatExpSet>
79 :
public RatExpSet::const_visitor
86 using ratexp_t =
typename ratexpset_t::value_t;
88 using weight_t =
typename weightset_t::value_t;
93 using super_t =
typename ratexpset_t::const_visitor;
95 constexpr
static const char*
me() {
return "split"; }
111 return std::move(
res_);
132 for (
const auto& v: e)
137 res_ = std::move(res);
164 for (
const auto& m: l)
172 auto res =
product(e[0], e[1]);
173 for (
unsigned i = 2, n = e.size(); i < n; ++i)
175 res_ = std::move(res);
193 for (
const auto& e: l_split)
207 for (
const auto& m: l)
216 for (
unsigned i = 2, n = e.size(); i < n; ++i)
218 res_ = std::move(res);
233 e.sub()->accept(*
this);
239 e.sub()->accept(*
this);
254 template <
typename RatExpSet>
257 split(
const RatExpSet& rs,
const typename RatExpSet::value_t& e)
268 template <
typename RatExpSet>
272 const auto& e = exp->as<RatExpSet>();
273 const auto& rs = e.ratexpset();
276 vcsn::split<RatExpSet>(rs, e.ratexp()));
285 template <
typename RatExpSet>
287 rat::ratexp_polynomial_t<RatExpSet>
294 for (
const auto& m: p)
295 res = ps.add(res, ps.lmul(m.second,
split(m.first)));
300 template <
typename PolynomialSet>
302 typename PolynomialSet::value_t
304 const typename PolynomialSet::value_t& p)
306 using polynomial_t =
typename PolynomialSet::value_t;
308 const auto& rs = *ps.labelset();
310 for (
const auto& m: p)
311 res = ps.add(res, ps.lmul(m.second,
split(rs, m.first)));
320 template <
typename PolynomialSet>
324 const auto& p = poly->as<PolynomialSet>();
325 const auto& ps = p.polynomialset();
328 vcsn::split_polynomial<PolynomialSet>(ps, p.polynomial()));
339 #endif // !VCSN_ALGOS_SPLIT_HH
Linear combination of labels: map labels to weights.
polynomial_t conjunction(const polynomial_t &l, const ratexp_t &r)
The split-product of l with r.
PolynomialSet::value_t split_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Split a polynomial of ratexps.
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)
polynomial split_polynomial(const polynomial &poly)
Bridge.
labelset_t_of< context_t > labelset_t
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &polynomial)
ratexp_polynomialset_t< RatExpSet > make_ratexp_polynomialset(const RatExpSet &rs)
From a RatExpSet to its polynomialset.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
polynomial_t operator()(const ratexp_t &v)
Break a ratexp into a polynomial.
Break a rational expression into a polynomial.
const weightset_ptr & weightset() const
typename ratexpset_t::value_t ratexp_t
polynomial_t conjunction(const ratexp_t &l, const ratexp_t &r)
The split-product of l with r.
weightset_t ws_
Shorthand to the weightset.
VCSN_RAT_VISIT(lweight, e)
split_visitor(const ratexpset_t &rs)
value_t rmul(const value_t &v, const weight_t &w) const
Right exterior product.
polynomialset< context< RatExpSet, weightset_t_of< RatExpSet >>> ratexp_polynomialset_t
Type of PolynomialSet of RatExps from the RatExpSet type.
polynomial_t product(const ratexp_t &l, const ratexp_t &r)
The split-product of l with r.
const value_t & zero() const
std::shared_ptr< detail::ratexp_base > ratexp
value_t lmul(const weight_t &w, const value_t &v) const
Left exterior product.
typename polynomialset_t::value_t polynomial_t
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
VCSN_RAT_VISIT(prod, e)
Handle an n-ary product.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
polynomial_t res_
The result.
weightset_t_of< ratexpset_t > weightset_t
value_t add(const value_t &l, const value_t &r) const
The sum of polynomials l and r.
typename ratexpset_t::const_visitor super_t
polynomial_t product(const polynomial_t &l, const ratexp_t &r)
The split-product of l with r.
Provide a variadic mul on top of a binary mul(), and one().
std::shared_ptr< const detail::context_base > context
An inner node implementing a weight.
typename ratexp_polynomialset_t< RatExpSet >::value_t ratexp_polynomial_t
Type of polynomials of ratexps from the RatExpSet type.
std::map< label_t, weight_t, vcsn::less< labelset_t >> value_t
label_t_of< context_t > label_t
VCSN_RAT_VISIT(conjunction, e)
Handle an n-ary conjunction.
value_t & del_weight(value_t &v, const label_t &w) const
Remove the monomial of w in v.
context_t_of< ratexpset_t > context_t
polynomial_t split(const ratexp_t &v)
Easy recursion.
typename weightset_t::value_t weight_t
rat::ratexp_polynomial_t< RatExpSet > split(const RatExpSet &rs, const typename RatExpSet::value_t &e)
Split a ratexp.
const weight_t get_weight(const value_t &v, const label_t &w) const ATTRIBUTE_PURE
polynomial split(const ratexp &exp)
Bridge.
std::shared_ptr< const detail::polynomial_base > polynomial
static constexpr const char * me()
VCSN_RAT_VISIT(rweight, e)