18 template <
typename ExpSet>
24 template <
typename ExpSet>
29 template <
typename ExpSet>
33 using context_t =
context<ExpSet,
74 template <
typename ExpSet>
76 :
public ExpSet::const_visitor
85 using weight_t =
typename weightset_t::value_t;
90 using super_t =
typename expressionset_t::const_visitor;
92 template <type_t Type>
96 constexpr
static const char*
me() {
return "split"; }
112 return std::move(res_);
122 auto res = ps_.zero();
123 for (
const auto&
v: e)
126 ps_.add_here(
res, res_);
128 res_ = std::move(
res);
139 weight_t l_split_const = ps_.get_weight(l_split, rs_.one());
141 ps_.del_weight(l_split, rs_.one());
144 auto res = ps_.zero();
145 for (
const auto& e: l_split)
149 ps_.lweight(l_split_const,
split(r)));
158 auto res = ps_.zero();
160 for (
const auto& m: l)
171 for (
unsigned i = 2, n = e.size(); i < n; ++i)
173 res_ = std::move(
res);
177 #define DEFINE(Type) \ 178 VCSN_RAT_VISIT(Type, e) \ 180 res_ = polynomial_t{{e.shared_from_this(), ws_.one()}}; \ 199 raise(me(),
": tuple is not supported");
204 e.sub()->accept(*
this);
205 res_ = ps_.lweight(e.weight(), res_);
210 e.sub()->accept(*
this);
211 res_ = ps_.rweight(res_, e.weight());
225 template <
typename ExpSet>
227 split(
const ExpSet& rs,
const typename ExpSet::value_t& e)
238 template <
typename ExpSet>
242 const auto& e = exp->as<ExpSet>();
243 const auto& rs = e.valueset();
245 return {ps, vcsn::split<ExpSet>(rs, e.value())};
251 template <
typename PolynomialSet>
252 typename PolynomialSet::value_t
254 const typename PolynomialSet::value_t& p)
257 const auto& rs = *ps.labelset();
258 auto res = ps.zero();
259 for (
const auto& m: p)
265 template <
typename ExpSet>
277 template <
typename PolynomialSet>
281 const auto& p = poly->
as<PolynomialSet>();
282 const auto& ps = p.valueset();
283 return {ps, vcsn::split_polynomial<PolynomialSet>(ps, p.value())};
VCSN_RAT_VISIT(lweight, e)
typename expressionset_t::value_t expression_t
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
polynomial_t res_
The result.
typename super_t::template variadic_t< Type > variadic_t
auto multiply(const Aut1 &lhs, const Aut2 &rhs, Tag tag={}) -> decltype(lhs->null_state(), rhs->null_state(), detail::make_join_automaton(tag, lhs, rhs))
Concatenate two automata, general case.
polynomial_t multiply(const expression_t &l, const expression_t &r)
The split-multiplation of l with r.
void visit(const tuple_t &, std::true_type) override
An inner node with multiple children.
PolynomialSet::value_t split_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Split a polynomial of expressions, given the polynomialset.
polynomial_t multiply(const polynomial_t &l, const expression_t &r)
The split-multiplation of l with r.
auto & as()
Extract wrapped typed value.
rat::expression_polynomial_t< ExpSet > split(const ExpSet &rs, const typename ExpSet::value_t &e)
Split an expression.
split_visitor(const expressionset_t &rs)
value_impl< detail::polynomial_tag > polynomial
An inner node to name the subexpression.
typename detail::context_t_of_impl< base_t< ValueSet > >::type context_t_of
Provide a variadic mul on top of a binary mul(), and one().
typename expression_polynomialset_t< ExpSet >::value_t expression_polynomial_t
Type of polynomials of expressions from the ExpSet type.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
polynomial_t split(const expression_t &v)
Easy recursion.
typename expressionset_t::const_visitor super_t
typename weightset_t::value_t weight_t
weightset_mixin< detail::polynomialset_impl< Context, Kind > > polynomialset
#define DEFINE(Type)
These are just propagated as monomials.
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
typename super_t::tuple_t tuple_t
context_t_of< expressionset_t > context_t
labelset_t_of< context_t > labelset_t
polynomial_t operator()(const expression_t &v)
Break an expression into a polynomial.
polynomialset< context< ExpSet, weightset_t_of< ExpSet > >> expression_polynomialset_t
Type of PolynomialSet of expressions from the ExpSet type.
An inner node implementing a weight.
static constexpr const char * me()
Name of this algorithm, for error messages.
weightset_t_of< expressionset_t > weightset_t
VCSN_RAT_VISIT(mul, e)
Handle an n-ary multiplication.
auto weight_of(const welement< Label, Weight > &m) -> decltype(m.weight())
The weight of a welement.
auto label_of(const welement< Label, Weight > &m) -> decltype(m.label())
The label of a welement.
label_t_of< context_t > label_t
value_impl< detail::expression_tag > expression
expression_polynomialset_t< ExpSet > make_expression_polynomialset(const ExpSet &rs)
From a ExpSet to its polynomialset.
VCSN_RAT_VISIT(rweight, e)
Break a rational expression into a polynomial.
const weightset_ptr & weightset() const
typename polynomialset_t::value_t polynomial_t