17 #ifndef AWALI_ALGOS_SPLIT_HH
18 # define AWALI_ALGOS_SPLIT_HH
25 namespace awali {
namespace sttc {
34 template <
typename RatExpSet>
40 template <
typename RatExpSet>
45 template <
typename RatExpSet>
50 using context_t =
context<RatExpSet,
63 template <
typename RatExpSet>
65 :
public RatExpSet::const_visitor
72 using ratexp_t =
typename ratexpset_t::value_t;
74 using weight_t =
typename weightset_t::value_t;
81 constexpr
static const char*
me() {
return "split"; }
97 return std::move(res_);
118 for (
const auto& v: e)
123 res_ = std::move(res);
150 for (
const auto& m: l)
158 auto res =
product(e[0], e[1]);
159 for (
unsigned i = 2,
n = e.size(); i <
n; ++i)
161 res_ = std::move(res);
179 for (
const auto& e: l_split)
180 ps_.
add_here(res, rs_.conjunction(e.first,
r), e.second);
193 for (
const auto& m: l)
202 for (
unsigned i = 2,
n = e.size(); i <
n; ++i)
204 res_ = std::move(res);
219 e.sub()->accept(*
this);
220 res_ = ps_.
lmul(e.weight(), res_);
225 e.sub()->accept(*
this);
226 res_ = ps_.
rmul(res_, e.weight());
240 template <
typename RatExpSet>
242 rat::ratexp_polynomial_t<RatExpSet>
243 split(
const RatExpSet& rs,
const typename RatExpSet::ratexp_t& e)
250 template <
typename RatExpSet>
252 rat::ratexp_polynomial_t<RatExpSet>
259 for (
const auto& m: p)
260 res = ps.add(res, ps.lmul(m.second,
split(m.first)));
carries the algebraic settings of automata
Definition: context.hh:40
const weightset_ptr & weightset() const
Definition: context.hh:157
The semiring of Natural numbers.
Definition: n.hh:34
Linear combination of labels: map labels to weights.
Definition: polynomialset.hh:69
std::map< label_t, weight_t, internal::less< labelset_t > > value_t
Definition: polynomialset.hh:83
value_t & add_here(value_t &v, const value_t &p) const
v += p.
Definition: polynomialset.hh:130
value_t & del_weight(value_t &v, const label_t &w) const
Remove the monomial of w in v.
Definition: polynomialset.hh:111
value_t add(const value_t &l, const value_t &r) const
The sum of polynomials l and r.
Definition: polynomialset.hh:182
const weight_t get_weight(const value_t &v, const label_t &w) const ATTRIBUTE_PURE
Definition: polynomialset.hh:171
const value_t & zero() const
Definition: polynomialset.hh:353
value_t rmul(const value_t &v, const weight_t &w) const
Right exterior product.
Definition: polynomialset.hh:266
value_t lmul(const weight_t &w, const value_t &v) const
Left exterior product.
Definition: polynomialset.hh:241
value_t rmul_letter(const value_t &v, const label_t &rhs) const
Right product.
Definition: polynomialset.hh:277
The semiring of floating Numbers.
Definition: r.hh:35
Definition: ratexp.hh:280
Definition: ratexp.hh:262
polynomial_t product(const polynomial_t &l, const ratexp_t &r)
The split-product of l with r.
Definition: split.hh:147
AWALI_RAT_VISIT(atom, e)
Definition: split.hh:110
polynomial_t conjunction(const ratexp_t &l, const ratexp_t &r)
The split-product of l with r.
Definition: split.hh:168
RatExpSet ratexpset_t
Definition: split.hh:68
typename weightset_t::value_t weight_t
Definition: split.hh:74
AWALI_RAT_VISIT(rweight, e)
Definition: split.hh:223
AWALI_RAT_VISIT(one,)
Definition: split.hh:105
typename polynomialset_t::value_t polynomial_t
Definition: split.hh:77
polynomial_t product(const ratexp_t &l, const ratexp_t &r)
The split-product of l with r.
Definition: split.hh:130
ratexp_polynomialset_t< ratexpset_t > polynomialset_t
Definition: split.hh:76
weightset_t_of< ratexpset_t > weightset_t
Definition: split.hh:73
AWALI_RAT_VISIT(sum, e)
Definition: split.hh:115
typename ratexpset_t::const_visitor super_type
Definition: split.hh:79
AWALI_RAT_VISIT(prod, e)
Handle an n-ary product.
Definition: split.hh:156
polynomial_t operator()(const ratexp_t &v)
Break a ratexp into a polynomial.
Definition: split.hh:88
polynomial_t conjunction(const polynomial_t &l, const ratexp_t &r)
The split-product of l with r.
Definition: split.hh:190
labelset_t_of< context_t > labelset_t
Definition: split.hh:70
typename ratexpset_t::value_t ratexp_t
Definition: split.hh:72
polynomial_t split(const ratexp_t &v)
Easy recursion.
Definition: split.hh:94
constexpr static const char * me()
Definition: split.hh:81
AWALI_RAT_VISIT(zero,)
Definition: split.hh:100
AWALI_RAT_VISIT(conjunction, e)
Handle an n-ary conjunction.
Definition: split.hh:199
context_t_of< ratexpset_t > context_t
Definition: split.hh:69
AWALI_RAT_VISIT(lweight, e)
Definition: split.hh:217
split_visitor(const ratexpset_t &rs)
Definition: split.hh:83
label_t_of< context_t > label_t
Definition: split.hh:71
Definition: ratexp.hh:176
An inner node with multiple children.
Definition: ratexp.hh:115
An inner node implementing a weight.
Definition: ratexp.hh:208
typename ratexp_polynomialset_t< RatExpSet >::value_t ratexp_polynomial_t
Type of polynomials of ratexps from the RatExpSet type.
Definition: split.hh:42
ratexp_polynomialset_t< RatExpSet > make_ratexp_polynomialset(const RatExpSet &rs)
From a RatExpSet to its polynomialset.
Definition: split.hh:48
typename internal::label_t_of_impl< internal::base_t< ValueSet > >::type label_t_of
Helper to retrieve the type of the labels of a value set.
Definition: traits.hh:71
typename internal::context_t_of_impl< internal::base_t< ValueSet > >::type context_t_of
Helper to retrieve the type of the context of a value set.
Definition: traits.hh:66
typename internal::labelset_t_of_impl< internal::base_t< ValueSet > >::type labelset_t_of
Helper to retrieve the type of the labelset of a value set.
Definition: traits.hh:76
rat::ratexp_polynomial_t< RatExpSet > split(const RatExpSet &rs, const typename RatExpSet::ratexp_t &e)
Split a ratexp.
Definition: split.hh:243
typename internal::weightset_t_of_impl< internal::base_t< ValueSet > >::type weightset_t_of
Helper to retrieve the type of the weightset of a value set.
Definition: traits.hh:86
Main namespace of Awali.
Definition: ato.hh:22
#define AWALI_RAT_UNSUPPORTED(Type)
Definition: visitor.hh:73