9 #include <boost/optional.hpp> 10 #include <boost/range/algorithm/equal.hpp> 11 #include <boost/range/algorithm/find_if.hpp> 12 #include <boost/range/algorithm/lexicographical_compare.hpp> 35 # pragma clang diagnostic push 36 # pragma clang diagnostic ignored "-Wunused-value" 38 template <
typename LabelSet>
39 auto label_is_zero(
const LabelSet& ls,
const typename LabelSet::value_t* l)
40 -> decltype(ls.is_zero(l), bool())
42 return ls.is_zero(*l);
46 # pragma clang diagnostic pop 49 template <
typename LabelSet>
53 template <
typename LabelSet>
61 template <
typename WeightSet>
71 template <
typename Context, wet_kind_t Kind>
78 template <
typename Context, wet_kind_t Kind>
90 using label_t =
typename labelset_t::value_t;
114 const self_t&
self()
const {
return static_cast<const self_t&
>(*this); }
130 return weightset_t::has_lightening_weights();
152 assert(!weightset()->is_zero(w));
161 if (weightset()->is_zero(w))
162 return del_weight(v, l);
164 return new_weight(v, l, w);
172 return weightset()->zero();
208 auto w2 = weightset()->add(
weight_of(*i), k);
209 if (weightset()->is_zero(w2))
226 template <wet_kind_t WetType,
typename WS>
232 for (
const auto& m:
r)
238 template <wet_kind_t WetType,
typename WS>
242 && std::is_same<WS, b>::value),
250 template <wet_kind_t WetType,
typename WS>
254 && std::is_same<WS, f2>::value),
264 return add_here_impl_<value_t::kind, weightset_t>(l,
r);
289 raise(*
this,
": sub_here: invalid arguments: ",
297 if (weightset()->is_zero(w2))
311 for (
const auto& rm: r)
331 template <wet_kind_t WetType>
338 for (
const auto& lm: l)
339 for (
const auto& rm:
r)
348 template <wet_kind_t WetType>
354 return l.set() &
r.set();
362 return mul_impl_<value_t::kind>(l,
r);
371 for (
const auto& m: p)
385 template <
typename Ctx>
386 std::enable_if_t<Ctx::is_lar, value_t>
390 for (
const auto& lm: l)
391 for (
const auto& rm: r)
400 template <
typename Ctx>
401 std::enable_if_t<!Ctx::is_lar, value_t>
405 for (
const auto& p: zip_maps<vcsn::as_tuple>(l, r))
408 weightset()->mul(
weight_of(std::get<0>(p)),
416 return conjunction_impl_<context_t>(l,
r);
425 for (
const auto& lm: l)
426 for (
const auto& rm: r)
435 template <wet_kind_t WetType = value_t::kind>
441 auto res = weightset()->zero();
442 for (
const auto& p: zip_maps<vcsn::as_tuple>(l,
r))
443 res = weightset()->add(
res,
444 weightset()->mul(
weight_of(std::get<0>(p)),
451 template <wet_kind_t WetType = value_t::kind,
typename WS = weightset_t>
455 && std::is_same<WS, b>::value),
458 return l.set().intersects(
r.set());
463 template <wet_kind_t WetType = value_t::kind,
typename WS = weightset_t>
467 && std::is_same<WS, f2>::value),
470 return (l.set() &
r.set()).count() % 2;
477 for (
const auto& m: v)
493 auto i = v.find(labelset()->one());
495 return {{i->first, weightset()->star(i->second)}};
505 if (weightset()->is_one(w))
507 else if (!weightset()->is_zero(w))
508 for (
const auto& m: v)
518 for (
const auto& m: v)
530 for (
const auto& m: v)
538 template <
typename Ctx>
545 template <
typename Ctx>
554 if (weightset()->is_one(w))
556 else if (!weightset()->is_zero(w))
557 for (
const auto& m:
v)
561 static_if<has_rweight_fn<context_t>{}>
562 ([
this, &
res] (
const auto& ls,
const auto& m,
const auto& w)
568 [
this, &
res] (
const auto&,
const auto& m,
const auto& w)
583 for (
const auto& lhs: v)
585 labelset()->mul(
label_of(lhs), rhs),
595 for (
const auto& lhs: l)
605 raise(*
this,
": rdivide: not implemented (",
622 for (
const auto& m: r)
629 template <
typename Ctx = context_t>
630 std::enable_if_t<Ctx::is_lar, value_t&>
633 for (
const auto& lm: l)
634 for (
const auto& rm: r)
641 template <
typename Ctx = context_t>
642 std::enable_if_t<!Ctx::is_lar, value_t&>
646 raise(*
this,
": ldivide: division by zero");
650 while (!is_zero(remainder))
654 remainder = sub(remainder, mul(l,
factor));
657 if (!is_zero(remainder))
658 raise(*
this,
": ldivide: not implemented (",
669 add_ldivide_here(res, l, r);
677 if (!weightset()->is_one(w))
687 if (!weightset()->is_one(w))
705 auto i = begin(lhs), i_end = end(lhs);
706 auto j = begin(rhs), j_end = end(rhs);
708 i != i_end && j != j_end
709 && labelset()->equal(i->first, j->first);
711 res.set(i->first, weightset()->
lgcd(i->second, j->second));
714 if (i != i_end || j != j_end)
724 template <
typename WeightSet,
typename Dummy =
void>
735 template <
typename Dummy>
742 for (
const auto& m: v)
751 template <
typename Ctx, wet_kind_t Knd,
typename Dummy>
759 for (
const auto& p: v)
772 return weightset()->zero();
788 if (!weightset()->is_zero(
res))
789 ldivide_here(
res, v);
808 template <
typename... Polys>
817 this->labelset()->
tuple(ms.first...),
818 this->weightset()->mul(ms.second...));
820 std::forward<Polys>(vs)...);
825 template <
size_t Tape>
832 template <
size_t Tape>
835 auto ps = project<Tape>();
836 auto res = ps.zero();
837 for (
const auto& m: v)
839 labelset()->
template project<Tape>(
label_of(m)),
849 template <
typename Ctx>
856 template <
typename Ctx>
862 template <
typename Ctx = context_t>
865 -> std::enable_if_t<are_composable<Ctx, Ctx>{},
value_t>
868 for (
const auto& lm: l)
869 for (
const auto& rm:
r)
870 if (labelset()->
template set<0>().equal(std::get<1>(
label_of(lm)),
880 template <
typename Ctx = context_t>
883 -> std::enable_if_t<has_compose_fn<Ctx>{},
value_t>
886 for (
const auto& lm: l)
887 for (
const auto& rm: r)
904 label_t res = labelset()->zero();
905 for (
const auto& m: v)
906 res = labelset()->add(res,
917 return {to_label(v), w};
925 return {{labelset()->complement(to_label(
normalize(v))),
926 weightset()->one()}};
941 template <wet_kind_t WetType>
948 return boost::equal(l, r, monomial_equal);
951 template <wet_kind_t WetType>
958 return l.set() == r.set();
966 return equal_impl_<value_t::kind>(l,
r);
972 static value_t res{monomial_one()};
991 return weightset_t::is_one(i->second);
1010 return weightset_t::star_status();
1023 template <
typename WS>
1025 conv(
const WS& ws,
const typename WS::value_t&
v)
const 1027 return {{labelset()->one(), weightset()->conv(ws, v)}};
1031 template <
typename C, wet_kind_t K>
1036 const typename C::labelset_t& sls = *sps.labelset();
1037 const typename C::weightset_t& sws = *sps.weightset();
1041 for (
const auto& m: v)
1061 template <wet_kind_t WetType>
1071 template <wet_kind_t WetType>
1078 return l.set() - r.set();
1085 return compare_impl_<value_t::kind>(l,
r);
1104 template <wet_kind_t WetType>
1111 return boost::range::lexicographical_compare(l, r, monomial_less);
1114 template <wet_kind_t WetType>
1121 return l.set() < r.set();
1128 return less_impl_<value_t::kind>(l,
r);
1141 auto label_transpose
1142 = static_if<context_t::is_lar>
1143 ([](
const auto& ls,
const auto& l) {
return ls.transposition(l); },
1144 [](
const auto& ls,
const auto& l) {
return ls.transpose(l); });
1145 for (
const auto& i: v)
1146 res.set(label_transpose(*labelset(),
label_of(i)),
1163 template <wet_kind_t WetType>
1171 for (
const auto& m: p)
1176 template <wet_kind_t WetType>
1189 return hash_impl_<value_t::kind>(
v);
1197 eat(is,
"polynomialset<");
1198 auto ctx = Context::make(is);
1209 o <<
"\\mathsf{Poly}[";
1214 o <<
"polynomialset<";
1221 context().print_set(o, fmt); 1236 boost::optional<label_t> 1237 conv_label(std::istream& i, bool weighted, const char sep = '+
') const 1239 int peek = i.peek(); 1240 assert(peek != '[
'); 1244 if (i.peek() == 'z
') 1253 // The label is not \z. 1254 // Check if there is a label that comes. Or rather, check if 1255 // there is something else than EOF or the separator, in which 1256 // case it must be a label. 1258 if (peek == EOF || peek == sep || isspace(peek)) 1260 // There is no label. This counts as '$
', the special 1263 // Indeed, that's how we represent the initial and
final 1272 *
this,
": conv: invalid monomial: ",
1274 " (did you mean \\e or \\z?)");
1275 res = labelset()->special();
1279 auto pos = i.tellg();
1280 res = labelset()->conv(i);
1290 require(i.peek() == EOF || pos < i.tellg(),
1291 *
this,
": invalid implicit empty word before: ", i);
1300 if (i.peek() == langle)
1311 return weightset()->one();
1320 boost::optional<monomial_t>
1323 #define SKIP_SPACES() \ 1324 while (isspace(i.peek())) \ 1329 if (i.peek() == EOF)
1333 bool weighted = i.peek() == langle;
1338 auto l = conv_label(i, weighted, sep);
1339 require(l, *
this,
": \\z is invalid for monomials");
1353 conv(std::istream& i,
const char sep =
'+')
const 1356 #define SKIP_SPACES() \ 1357 while (isspace(i.peek())) \ 1364 bool weighted = i.peek() == langle;
1370 if (i.peek() ==
'[')
1371 labelset()->convs(i, [
this, &res, &w](
const label_t& l)
1375 else if (
auto l = conv_label(i, weighted, sep))
1377 require(l, *
this,
": \\z is invalid for monomials");
1383 if (i.peek() == sep)
1399 static bool parens = getenv(
"VCSN_PARENS");
1403 labelset()->print(
label_of(m), out, fmt.for_labels());
1418 const std::string& sep =
" + ")
const 1443 static bool parens = getenv(
"VCSN_PARENS");
1444 if (parens || weightset()->show_one() || !weightset()->is_one(w))
1449 weightset()->print(w, out, fmt.for_weights());
1461 const std::string& sep)
const 1464 for (
const auto& m: v)
1478 const std::string& sep)
const 1485 using labels_t = std::vector<label_t>;
1491 for (
const auto& m: v)
1492 if (!labelset()->is_one(
label_of(m)))
1497 std::pair<weight_t, labels_t>,
1499 for (
const auto& p: per_weight)
1501 if (p.second.size() < 3)
1502 for (
auto l: p.second)
1503 per_label[l] = std::make_pair(p.first, labels_t{l});
1517 for (
const auto& p: per_label)
1524 print_weight_(p.second.first, out, fmt);
1526 if (1 < p.second.second.size())
1539 template <
typename Ctx = context_t>
1544 const std::string& sep =
" + ")
const 1546 return print_without_classes_(v, out, fmt, sep);
1551 template <
typename Ctx = context_t>
1556 const std::string& sep =
" + ")
const 1559 if (sep ==
" + " || v.size() <= 2)
1560 return print_without_classes_(v, out, fmt, sep);
1562 return print_with_classes_(v, out, fmt, sep);
1570 constexpr
static char langle =
'<';
1572 constexpr
static char rangle =
'>';
1575 template <
typename Context,
1576 wet_kind_t Kind = detail::wet_kind<labelset_t_of<Context>,
1594 return {
vcsn::join(ps1.context(), ps2.context())};
1607 return {*ps1.labelset(),
vcsn::join(*ps1.weightset(), ws2)};
value_t & del_weight(value_t &v, const label_t &l) const
Remove the monomial of l in v.
labelset_t_of< context_t > labelset_t
typename labelset_t::value_t label_t
Polynomials over labels.
void weight_set(welement< Label, Weight > &m, const Weight &w)
Set the weight of a welement.
std::ostream & print_without_classes_(const value_t &v, std::ostream &out, format fmt, const std::string &sep) const
Print a polynomial value without classes.
static ATTRIBUTE_PURE bool less(const value_t &l, const value_t &r)
Print as a parsable type string.
value_t lmul_label(const label_t &lhs, const value_t &v) const
Left product by a label.
for(const auto &lm:l) for(const auto &rm return res
static ATTRIBUTE_PURE auto less_impl_(const value_t &l, const value_t &r) -> std::enable_if_t< WetType==wet_kind_t::bitset, bool >
static ATTRIBUTE_PURE bool monomial_equal(const monomial_t &lhs, const monomial_t &rhs)
const weight_t get_weight(const value_t &v, const label_t &l) const ATTRIBUTE_PURE
value_t & add_here(value_t &l, const value_t &r) const
Container::value_type front(const Container &container)
The first member of this Container.
ATTRIBUTE_NORETURN void raise_not_starrable(const WeightSet &ws, const typename WeightSet::value_t &w)
This value is not starrable.
auto label_is_zero(const LabelSet &ls, const typename LabelSet::value_t *l) -> decltype(ls.is_zero(l), bool())
std::ostream & print_weight_(const weight_t w, std::ostream &out, format fmt) const
Print a weight.
value_t & sub_here(value_t &v, const monomial_t &m) const
v -= m.
auto rweight(const value_t &v, const weight_t w) const -> value_t
Right exterior product.
value_t star(const value_t &v) const
The star of polynomial v.
wet_kind_t
Different implementations of wets.
auto mul_impl_(const value_t &l, const value_t &r) const -> std::enable_if_t< WetType==wet_kind_t::bitset, value_t >
The product of polynomials l and r.
auto tuple(const Auts &... as)
Build the (accessible part of the) tuple.
weight_t conv_weight(std::istream &i) const
Read a weight, if there is one, bracketed.
label_t to_label(const value_t &v) const
Convert into a label.
auto scalar_product(const value_t &l, const value_t &r) const -> std::enable_if_t<(WetType==wet_kind_t::bitset &&std::is_same< WS, f2 >::value), weight_t >
The sum of the weights of the common labels.
auto add_here_impl_(value_t &l, const value_t &r) const -> std::enable_if_t<(WetType==wet_kind_t::bitset &&std::is_same< WS, b >::value), value_t &>
v += p, B and bitsets.
typename context_t::labelset_ptr labelset_ptr
static ATTRIBUTE_PURE auto hash_impl_(const value_t &p) -> std::enable_if_t< WetType==wet_kind_t::bitset, size_t >
value_t & add_here(value_t &v, const monomial_t &m) const
v += m.
void hash_combine(std::size_t &seed, const T &v)
std::enable_if_t< Ctx::is_lar, value_t & > add_ldivide_here(value_t &res, const value_t &l, const value_t &r) const
The left-division of polynomials l and r: res += l \ r.
static ATTRIBUTE_PURE auto compare_impl_(const value_t &l, const value_t &r) -> std::enable_if_t< WetType !=wet_kind_t::bitset, int >
const value_t & zero() const
std::ostream & print_with_classes_(const value_t &v, std::ostream &out, format fmt, const std::string &sep) const
Print a polynomial value with classes.
value_t & set_weight(value_t &v, const label_t &l, const weight_t w) const
Set the monomial of l in v to weight w.
weight_t normalize_here(value_t &v) const
Normalize v in place: compute the LGCD of the weights, ldivide the monomials with that factor...
Request the bitset implementation (bool weights).
auto add_here_impl_(value_t &l, const value_t &r) const -> std::enable_if_t< WetType !=wet_kind_t::bitset, value_t &>
v += p, default case.
static self_t make(std::istream &is)
Build from the description in is.
auto compose(const value_t &l, const value_t &r) const -> std::enable_if_t< are_composable< Ctx, Ctx >
The composition of polynomials l and r when the context is a composable tupleset. ...
auto compose(const value_t &l, const value_t &r) const -> std::enable_if_t< has_compose_fn< Ctx >
The composition of polynomials l and r when the context features compose.
value_t conv(std::istream &i, const char sep='+') const
Read a polynomial from a stream.
value_t & rdivide_here(value_t &v, const weight_t w) const
Right exterior division.
value_t infiltrate(const value_t &l, const value_t &r) const
The infiltration of polynomials l and r.
auto scalar_product(const value_t &l, const value_t &r) const -> std::enable_if_t<(WetType==wet_kind_t::bitset &&std::is_same< WS, b >::value), weight_t >
The sum of the weights of the common labels.
static ATTRIBUTE_PURE int monomial_compare(const monomial_t &lhs, const monomial_t &rhs)
const weightset_ptr & weightset() const
std::ostream & print_set(std::ostream &o, format fmt={}) const
void clear(value_t &v)
Set to zero.
static const value_t & one()
The unit polynomial.
Aut1 & add_here(Aut1 &res, const Aut2 &b, standard_tag)
Merge transitions of b into those of res.
static const monomial_t & monomial_one()
The unit monomial.
wet< label_t_of< Context >, weight_t_of< Context >, Kind, vcsn::less< labelset_t_of< Context > >, vcsn::hash< labelset_t_of< Context > >, vcsn::equal_to< labelset_t_of< Context > >> wet_of
The corresponding wet for a LabelSet -> WeightSet context.
value_t abs(const value_t &v) const
Map all weights to their absolute value.
value_t & ldivide_here(const weight_t w, value_t &v) const
Left exterior division.
monomial_t determinize(value_t v) const
"Determinize" this polynomial: turn into a monomial.
WeightSet::value_t operator()(const value_t &v) const
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
auto normalize(const Aut &a) -> decltype(copy(a))
Normalize a automaton.
static value_t conv(self_t, const value_t &v)
Conversion from (this and) other weightsets.
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
static ATTRIBUTE_PURE auto less_impl_(const value_t &l, const value_t &r) -> std::enable_if_t< WetType !=wet_kind_t::bitset, bool >
value_t conv(const WS &ws, const typename WS::value_t &v) const
FIXME: use enable_if to prevent this from being instantiated when WS is a polynomialset.
auto weight_of(const welement< Label, Weight > &m) -> decltype(m.weight())
The weight of a welement.
wet_of< context_t, Kind > value_t
static ATTRIBUTE_PURE auto equal_impl_(const value_t &l, const value_t &r) -> std::enable_if_t< WetType==wet_kind_t::bitset, bool >
polynomialset< Context, Kind > make_polynomialset(const Context &context)
static ATTRIBUTE_PURE int compare(const value_t &l, const value_t &r)
value_t transpose(const value_t &v) const
Transpose the labels and the weights.
auto label_of(const welement< Label, Weight > &m) -> decltype(m.label())
The label of a welement.
weightset_mixin< detail::r_impl > r
const labelset_ptr & labelset() const
auto tuple(Polys &&... vs) const -> value_t
Build a tuple of polynomials: (e.E+f.F)|(g.G+h.H) => eg.
monomial_t ldivide(const monomial_t &l, const monomial_t &r) const
Left division between two mononials: l \ r.
value_t & add_here(value_t &v, const label_t &l, const weight_t k) const
v += <k>l.
monomial_t mul(const monomial_t &l, const monomial_t &r) const
The product of monomials l and r.
Print as rich UTF-8 text, escaped.
value_t rdivide(const value_t &l, const value_t &r) const
const context_t & context() const
auto add_here_impl_(value_t &l, const value_t &r) const -> std::enable_if_t<(WetType==wet_kind_t::bitset &&std::is_same< WS, f2 >::value), value_t &>
v += p, F2 and bitsets.
std::ostream & print_set(std::ostream &o, format fmt={}) const
auto conjunction(const Aut &a, const Auts &... as)
Build the (accessible part of the) conjunction.
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
Request the map implementation.
std::ostream & print(const value_t &v, std::ostream &out, format fmt={}, const std::string &sep=" + ") const
Print a value (a polynomial).
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
value_t ldivide(const monomial_t &l, const value_t &r) const
Left division by a monomial: l \ r.
static type join(const polynomialset< Ctx1, Kind1 > &ps1, const polynomialset< Ctx2, Kind2 > &ps2)
auto mul(const value_t &p, const label_t &l, const weight_t w) const -> value_t
The product of polynomials l and r.
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
auto project(const value_t &v) const
Extract a single tape.
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
value_t lweight(const weight_t w, const value_t &v) const
Left exterior product.
auto conv(const ValueSet &vs, const std::string &str, Args &&... args) -> decltype(vs.conv(std::declval< std::istream &>(), std::forward< Args >(args)...))
Parse str via vs.conv.
static type join(const polynomialset< Ctx1, Kind1 > &ps1, const WS2 &ws2)
format for_labels() const
A copy of this format, but to print labels.
value_t normalize(value_t res) const
Normalized v.
std::enable_if_t<!is_letterized_t< labelset_t_of< Aut > >{}, bool > is_letterized(const Aut &aut)
static ATTRIBUTE_PURE bool monomial_less(const monomial_t &lhs, const monomial_t &rhs)
static constexpr bool show_one()
int lexicographical_cmp(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp)
Lexicographical three-way comparison between two ranges.
value_t conjunction(const value_t &l, const value_t &r) const
void print_(std::ostream &o, const T &arg, long)
Serialize arg into o.
auto norm(const value_t &v) const -> weight_t
The norm: the weight with which we should divide a polynomial to normalize it.
std::string bracketed(std::istream &i, char lbracket, char rbracket)
Extract the string which is here between lbracket and rbracket.
std::enable_if_t< Ctx::is_lar, value_t > conjunction_impl_(const value_t &l, const value_t &r) const
The conjunction of polynomials l and r.
This is useful to make hashes with labels or weights as keys without using non-default constructors; ...
An input/output format for valuesets.
Provide a variadic mul on top of a binary mul(), and one().
value_t rmul_label(const value_t &v, const label_t &rhs) const
Right product.
auto scalar_product(const value_t &l, const value_t &r) const -> std::enable_if_t< WetType !=wet_kind_t::bitset, weight_t >
The sum of the weights of the common labels.
Aut transpose(const transpose_automaton< Aut > &aut)
The transpose of a transpose automaton is the original automaton.
weight_t_of< context_t > weight_t
static ATTRIBUTE_PURE auto hash_impl_(const value_t &p) -> std::enable_if_t< WetType !=wet_kind_t::bitset, size_t >
constant< type_t::one, Context > one
A structure that implements the computation of join(V1, V2).
std::enable_if_t< labelset_t_of< Ctx >::is_letterized(), std::ostream & > print_(const value_t &v, std::ostream &out, format fmt={}, const std::string &sep=" + ") const
Print a non-null value for a letterized labelset (e.g., letterset or nullableset. ...
ValueSet::value_t lgcd(const ValueSet &vs, const typename ValueSet::value_t &lhs, const typename ValueSet::value_t &rhs)
Left-division of values.
bool is_zero(const value_t &v) const
auto mul(const value_t &l, const value_t &r) const -> value_t
The product of polynomials l and r.
static ATTRIBUTE_PURE bool equal(const value_t &l, const value_t &r)
Whether l == r.
std::enable_if_t<!Ctx::is_lar, value_t > conjunction_impl_(const value_t &l, const value_t &r) const
The conjunction of polynomials l and r.
std::enable_if_t<!Ctx::is_lar, value_t & > add_ldivide_here(value_t &res, const value_t &l, const value_t &r) const
The left-division of polynomials l and r: res += l \ r.
static ATTRIBUTE_PURE auto equal_impl_(const value_t &l, const value_t &r) -> std::enable_if_t< WetType !=wet_kind_t::bitset, bool >
Linear combination of labels: map labels to weights.
value_t sub(const value_t &l, const value_t &r) const
The subtraction of polynomials l and r.
value_t & new_weight(value_t &v, const label_t &l, const weight_t w) const
Set the monomial of l in v to weight w.
decltype(std::declval< labelset_t_of< Ctx > >() .compose(std::declval< label_t_of< Ctx > >(), std::declval< label_t_of< Ctx > >())) compose_t
Detect whether the labelset features compose.
weightset_t_of< context_t > weightset_t
char eat(std::istream &is, char c)
Check lookahead character and advance.
auto mul_impl_(const value_t &l, const value_t &r) const -> std::enable_if_t< WetType !=wet_kind_t::bitset, value_t >
The product of polynomials l and r.
value_t add(const value_t &l, const value_t &r) const
The sum of polynomials l and r.
typename value_t::value_type monomial_t
A pair <label, weight>.
std::enable_if_t<!labelset_t_of< Ctx >::is_letterized(), std::ostream & > print_(const value_t &v, std::ostream &out, format fmt={}, const std::string &sep=" + ") const
Print a non-null value for a non letterized labelset.
In the general case, normalize by the first (non null) weight.
static ATTRIBUTE_PURE size_t hash(const value_t &v)
polynomialset_impl(const context_t &ctx)
static constexpr star_status_t star_status()
static ATTRIBUTE_PURE auto compare_impl_(const value_t &l, const value_t &r) -> std::enable_if_t< WetType==wet_kind_t::bitset, int >
decltype(std::declval< labelset_t_of< Ctx > >() .rweight(std::declval< label_t_of< Ctx > >(), std::declval< weight_t_of< Ctx > >())) rweight_t
Detect whether the labelset features rweight.
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
std::ostream & print(const std::tuple< Args... > &args, std::ostream &o)
void cross(Fun f)
Variadic Cartesian product of containers.
Functor to compare Values of ValueSets.
void require(Bool b, Args &&... args)
If b is not verified, raise an error with args as message.
auto project() const
The polynomialset for tape Tape.
static constexpr bool has_lightening_weights()
ps_t::value_t operator()(const value_t &v) const
static ATTRIBUTE_PURE size_t hash(const monomial_t &m, size_t res=0)
value_t mul(const value_t &l, const monomial_t &rhs) const
Right product by a monomial.
int compare(const Lhs &lhs, const Rhs &rhs)
Comparison between lhs and rhs.
typename context_t::weightset_ptr weightset_ptr
z::value_t operator()(const value_t &v) const
auto factor(const Aut &aut) -> decltype(::vcsn::copy(aut))
static bool is_one(const value_t &v) ATTRIBUTE_PURE
Whether is the unit polynomial.
std::string to_string(direction d)
Conversion to string.
auto rdivide(const Aut1 &a1, const Aut2 &a2)
Compute the right quotient.
std::ostream & print(const monomial_t &m, std::ostream &out, format fmt={}) const
Print a monomial.
value_t lgcd(const value_t &lhs, const value_t &rhs) const
LGCD between two polynomials.
std::ostream & print_label_class(const LabelSet &ls, const std::vector< typename LabelSet::value_t > &letters, std::ostream &out, format fmt)
Print a set of labels (letterized) with classes.
value_t conv(const polynomialset< C, K > &sps, const typename polynomialset< C, K >::value_t &v) const
Convert from another polynomialset to type_t.
static symbol sname()
The static name.
value_t value(const label_t &l, const weight_t w) const
Create a polynomial with a single value.
boost::optional< monomial_t > conv_monomial(std::istream &i, const char sep='+') const
Read a monomial from a stream.
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
value_t complement(const value_t &v) const
Complement this polynomial.
value_t mul(const monomial_t &lhs, const value_t &v) const
Left product by a monomial.
value_t ldivide(const value_t &l, const value_t &r) const
Left division of two polynomials: l \ r.
static constexpr bool is_commutative()