19 template <
typename ExpSet>
25 template <
typename ExpSet>
30 template <
typename ExpSet>
35 using context_t =
context<ExpSet,
37 return context_t{
rs, *rs.weightset()};
76 template <
typename ExpSet>
78 :
public ExpSet::const_visitor
87 using weight_t =
typename weightset_t::value_t;
92 using super_t =
typename expressionset_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);
151 ps_.del_weight(l_split,
rs_.one());
154 return ps_.add(
ps_.rmul_label(l_split, r),
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);
189 ps_.del_weight(l_split,
rs_.one());
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);
228 virtual
void visit(const tuple_t&,
std::true_type)
override
230 raise(
me(),
": tuple is not supported");
240 e.sub()->accept(*
this);
246 e.sub()->accept(*
this);
261 template <
typename ExpSet>
264 split(
const ExpSet&
rs,
const typename ExpSet::value_t& e)
275 template <
typename ExpSet>
279 const auto& e = exp->as<ExpSet>();
280 const auto&
rs = e.expressionset();
283 vcsn::split<ExpSet>(rs, e.expression()));
289 template <
typename PolynomialSet>
291 typename PolynomialSet::value_t
293 const typename PolynomialSet::value_t& p)
295 using polynomial_t =
typename PolynomialSet::value_t;
297 const auto&
rs = *ps.labelset();
299 for (
const auto& m: p)
305 template <
typename ExpSet>
307 rat::expression_polynomial_t<ExpSet>
318 template <
typename PolynomialSet>
322 const auto& p = poly->as<PolynomialSet>();
323 const auto& ps = p.polynomialset();
326 vcsn::split_polynomial<PolynomialSet>(ps, p.polynomial()));
polynomial_t conjunction(const polynomial_t &l, const expression_t &r)
The split-product of l with r.
virtual void visit(const tuple_t &, std::true_type) override
polynomialset< context< ExpSet, weightset_t_of< ExpSet >>> expression_polynomialset_t
Type of PolynomialSet of expressions from the ExpSet type.
typename expression_polynomialset_t< ExpSet >::value_t expression_polynomial_t
Type of polynomials of expressions from the ExpSet type.
VCSN_RAT_VISIT(lweight, e)
#define VCSN_RAT_UNSUPPORTED(Type)
std::shared_ptr< const detail::polynomial_base > polynomial
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
polynomial_t split(const expression_t &v)
Easy recursion.
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
polynomial split(const expression &exp)
Bridge.
typename expressionset_t::value_t expression_t
PolynomialSet::value_t split_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Split a polynomial of expressions, given the polynomialset.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Provide a variadic mul on top of a binary mul(), and one().
An inner node with multiple children.
auto weight_of(const welement< Label, Weight > &m) -> decltype(m.weight())
The weight of a welement.
VCSN_RAT_VISIT(rweight, e)
weightset_mixin< detail::polynomialset_impl< Context, Kind >> polynomialset
polynomial_t res_
The result.
typename super_t::tuple_t tuple_t
std::shared_ptr< const detail::context_base > context
A dyn::context.
typename weightset_t::value_t weight_t
polynomial_t product(const expression_t &l, const expression_t &r)
The split-product of l with r.
polynomial split_polynomial(const polynomial &poly)
Bridge (split).
weightset_t ws_
Shorthand to the weightset.
VCSN_RAT_VISIT(prod, e)
Handle an n-ary product.
labelset_t_of< context_t > labelset_t
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
auto label_of(const welement< Label, Weight > &m) -> decltype(m.label())
The label of a welement.
polynomial_t conjunction(const expression_t &l, const expression_t &r)
The split-product of l with r.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
typename expressionset_t::const_visitor super_t
An inner node implementing a weight.
Break a rational expression into a polynomial.
split_visitor(const expressionset_t &rs)
VCSN_RAT_VISIT(conjunction, e)
Handle an n-ary conjunction.
weightset_t_of< expressionset_t > weightset_t
std::shared_ptr< detail::expression_base > expression
polynomial_t product(const polynomial_t &l, const expression_t &r)
The split-product of l with r.
static constexpr const char * me()
Name of this algorithm, for error messages.
expression_polynomialset_t< ExpSet > make_expression_polynomialset(const ExpSet &rs)
From a ExpSet to its polynomialset.
typename polynomialset_t::value_t polynomial_t
context_t_of< expressionset_t > context_t
polynomial_t operator()(const expression_t &v)
Break an expression into a polynomial.
rat::expression_polynomial_t< ExpSet > split(const ExpSet &rs, const typename ExpSet::value_t &e)
Split an expression.
label_t_of< context_t > label_t