![]() |
Vcsn
2.3a
Be Rational
|
#include <expansionset.hh>
Classes | |
struct | tuple_impl |
Denormalize a pack of one-tape expansions. More... | |
struct | value_t |
An expansion. More... | |
Public Types | |
using | expressionset_t = ExpSet |
using | self_t = expansionset |
using | context_t = context_t_of< expressionset_t > |
using | labelset_t = labelset_t_of< context_t > |
using | label_t = label_t_of< context_t > |
using | expression_t = typename expressionset_t::value_t |
using | weightset_t = weightset_t_of< expressionset_t > |
using | weight_t = typename weightset_t::value_t |
using | polynomialset_t = expression_polynomialset_t< expressionset_t > |
using | polynomial_t = typename polynomialset_t::value_t |
using | monomial_t = typename polynomialset_t::monomial_t |
using | polys_t = std::map< label_t, polynomial_t, vcsn::less< labelset_t >> |
template<unsigned Tape> | |
using | project_t = expansionset< typename expressionset_t::template project_t< Tape >> |
The type of the expansionset for tape Tape. More... | |
Public Member Functions | |
expansionset (const expressionset_t &rs) | |
const expressionset_t & | expressionset () const |
The expressionset. More... | |
const polynomialset_t & | polynomialset () const |
The polynomialset. More... | |
const context_t & | context () const |
The context. More... | |
std::ostream & | print_set (std::ostream &o, format fmt={}) const |
Print this valueset. More... | |
std::ostream & | print (const value_t &v, std::ostream &o, format fmt={}) const |
Print this expansion. More... | |
value_t & | normalize (value_t &res) const |
Normalize: move the constant term to the label one. More... | |
value_t & | normalize_ (value_t &res, std::true_type) const |
Normalize res. More... | |
value_t & | normalize_ (value_t &res, std::false_type) const |
Normalize when there is no label one: identity. More... | |
value_t & | denormalize (value_t &res) const |
Move the constant to the polynomial associated to one. More... | |
value_t & | denormalize_ (value_t &res, std::true_type) const |
Denormalize res move the constant to the polynomial associated to one. More... | |
value_t & | denormalize_ (value_t &res, std::false_type) const |
Denormalize when there is no label one: identity. More... | |
template<typename OtherExpSet > | |
value_t | conv (const expansionset< OtherExpSet > &other, const typename expansionset< OtherExpSet >::value_t &v) const |
Convert from another expansionset to self. More... | |
value_t | zero () const |
The zero. More... | |
value_t | one () const |
The one. More... | |
value_t | atom (const label_t &l) const |
A single label. More... | |
void | add_here (value_t &lhs, const value_t &rhs) const |
In place addition. More... | |
value_t | add (const value_t &lhs, const value_t &rhs) const |
Addition. More... | |
value_t | lweight (const weight_t &w, const value_t &rhs) const |
Left-multiplication by w of rhs. More... | |
value_t & | lweight_here (const weight_t &w, value_t &res) const |
Inplace left-multiplication by w of res. More... | |
value_t | rweight (const value_t &lhs, const weight_t &w) const |
Right-multiplication of lhs by w. More... | |
value_t & | rweight_here (value_t &res, const expression_t &rhs) const |
In place right multiplication by an expression. More... | |
value_t & | ldivide_here (const weight_t &w, value_t &res) const |
Inplace left-division by w of res. More... | |
value_t | conjunction (const value_t &l, const value_t &r) const |
The conjunction of l and r. More... | |
value_t | shuffle (const value_t &de, const expression_t &e, const value_t &df, const expression_t &f) const |
The shuffle product of de and df. More... | |
value_t | infiltrate (const value_t &de, const expression_t &e, const value_t &df, const expression_t &f) const |
The infiltration product of l and r. More... | |
value_t | complement (const value_t &v) const |
The complement of v. More... | |
value_t | transpose (const value_t &v) const |
Transpose an expansion. The firsts must be reduced to one. More... | |
value_t | ldivide (value_t lhs, value_t rhs) const |
value_t | determinize (const value_t &v) const |
Turn the polynomials into (normalized) monomials. More... | |
template<unsigned Tape> | |
auto | project () const -> project_t< Tape > |
The expansionset for tape Tape. More... | |
template<typename... Expansions> | |
auto | tuple (Expansions &&...es) const -> value_t |
The tuplization of single-tape expansions into a multitape expansion. More... | |
template<size_t Tape> | |
auto | project (const value_t &v) const |
Project a multitape expansion. More... | |
void | compose_with_one_ (value_t &, const value_t &, const value_t &, std::false_type) const |
void | compose_with_one_ (value_t &res, const value_t &l, const value_t &r, std::true_type) const |
template<typename Ctx = context_t> | |
auto | compose (value_t l, value_t r) const -> std::enable_if_t< are_composable< Ctx, Ctx > |
The composition of l and r. More... | |
denormalize (l) | |
denormalize (r) | |
for (const auto &lm:l.polynomials) for(const auto &rm | |
compose_with_one_ (res, l, r, has_one) | |
normalize (res) | |
Static Public Member Functions | |
static constexpr const char * | me () |
static symbol | sname () |
The static name. More... | |
static value_t | conv (self_t, const value_t &v) |
Conversion from (this and) other weightsets. More... | |
Private Member Functions | |
template<typename Conjunction > | |
void | conjunctions_with_one_ (value_t &, const value_t &, const value_t &, std::false_type, Conjunction) const |
template<typename Conjunction > | |
void | conjunctions_with_one_ (value_t &res, const value_t &l, const value_t &r, std::true_type, Conjunction conjunction) const |
template<typename LabelSet = labelset_t, typename Conjunction > | |
auto | conjunction_ (value_t l, value_t r, Conjunction conjunction) const -> std::enable_if_t< detail::is_letterized_t< LabelSet > |
The conjunction of l and r. More... | |
denormalize (l) | |
denormalize (r) | |
for (const auto &p:zip_maps(l.polynomials, r.polynomials)) res.polynomials[p.first] | |
conjunctions_with_one_ (res, l, r, has_one, conjunction) | |
normalize (res) | |
template<typename LabelSet = labelset_t, typename Conjunction > | |
auto | conjunction_ (const value_t &lhs, const value_t &rhs, Conjunction conjunction) const -> std::enable_if_t<!detail::is_letterized_t< LabelSet > |
The conjunction of l and r. More... | |
for (const auto &l:lhs.polynomials) for(const auto &r | |
template<typename Shuffle > | |
value_t & | shuffle_ (value_t &res, const value_t &lhs_xpn, const expression_t &lhs_xpr, const value_t &rhs_xpn, const expression_t &rhs_xpr, Shuffle shuffle) const |
The shuffle product of l and r. More... | |
template<bool IsLetterized> | |
std::enable_if_t<!IsLetterized, value_t > | complement_ (const value_t &) const |
Complement on an invalid labelset. More... | |
template<bool IsLetterized> | |
std::enable_if_t< IsLetterized, value_t > | complement_ (const value_t &v) const |
Complement on a letterized labelset. More... | |
Private Attributes | |
value_t | |
res | constant = ws_.mul(l.constant, r.constant) |
auto | has_one = bool_constant<context_t::has_one()>() |
return | res |
expressionset_t | rs_ |
The expressionset used for the expressions. More... | |
const labelset_t & | ls_ = *rs_.labelset() |
Shorthand to the labelset. More... | |
const weightset_t & | ws_ = *rs_.weightset() |
Shorthand to the weightset. More... | |
polynomialset_t | ps_ = make_expression_polynomialset(rs_) |
The polynomialset for the polynomials. More... | |
Definition at line 19 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::context_t = context_t_of<expressionset_t> |
Definition at line 24 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::expression_t = typename expressionset_t::value_t |
Definition at line 27 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::expressionset_t = ExpSet |
Definition at line 22 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::label_t = label_t_of<context_t> |
Definition at line 26 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::labelset_t = labelset_t_of<context_t> |
Definition at line 25 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::monomial_t = typename polynomialset_t::monomial_t |
Definition at line 33 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::polynomial_t = typename polynomialset_t::value_t |
Definition at line 32 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::polynomialset_t = expression_polynomialset_t<expressionset_t> |
Definition at line 31 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::polys_t = std::map<label_t, polynomial_t, vcsn::less<labelset_t>> |
Definition at line 40 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::project_t = expansionset<typename expressionset_t::template project_t<Tape>> |
The type of the expansionset for tape Tape.
Definition at line 606 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::self_t = expansionset |
Definition at line 23 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::weight_t = typename weightset_t::value_t |
Definition at line 29 of file expansionset.hh.
using vcsn::rat::expansionset< ExpSet >::weightset_t = weightset_t_of<expressionset_t> |
Definition at line 28 of file expansionset.hh.
|
inline |
Definition at line 49 of file expansionset.hh.
|
inline |
Addition.
Definition at line 255 of file expansionset.hh.
|
inline |
In place addition.
Definition at line 247 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
A single label.
Definition at line 241 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
The complement of v.
Definition at line 476 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inlineprivate |
Complement on an invalid labelset.
Definition at line 491 of file expansionset.hh.
|
inlineprivate |
Complement on a letterized labelset.
Definition at line 500 of file expansionset.hh.
|
inline |
The composition of l and r.
Definition at line 796 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::compose().
|
inline |
Definition at line 758 of file expansionset.hh.
|
inline |
Definition at line 764 of file expansionset.hh.
vcsn::rat::expansionset< ExpSet >::compose_with_one_ | ( | res | , |
l | , | ||
r | , | ||
has_one | |||
) |
|
inline |
The conjunction of l and r.
Definition at line 423 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inlineprivate |
The conjunction of l and r.
When labelset is letterized.
Definition at line 353 of file expansionset.hh.
|
inlineprivate |
The conjunction of l and r.
When labelset is not letterized.
Definition at line 376 of file expansionset.hh.
|
inlineprivate |
Definition at line 311 of file expansionset.hh.
|
inlineprivate |
Definition at line 319 of file expansionset.hh.
|
private |
|
inline |
The context.
Definition at line 74 of file expansionset.hh.
|
inlinestatic |
Conversion from (this and) other weightsets.
Definition at line 211 of file expansionset.hh.
|
inline |
Convert from another expansionset to self.
Definition at line 219 of file expansionset.hh.
|
inline |
Move the constant to the polynomial associated to one.
Definition at line 179 of file expansionset.hh.
|
private |
|
private |
vcsn::rat::expansionset< ExpSet >::denormalize | ( | l | ) |
vcsn::rat::expansionset< ExpSet >::denormalize | ( | r | ) |
|
inline |
Denormalize res move the constant to the polynomial associated to one.
Definition at line 187 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::denormalize().
|
inline |
Denormalize when there is no label one: identity.
Definition at line 200 of file expansionset.hh.
|
inline |
Turn the polynomials into (normalized) monomials.
Definition at line 590 of file expansionset.hh.
Referenced by vcsn::detail::derived_term_automaton_impl< ExpSet >::complete_via_expansion_().
|
inline |
The expressionset.
Definition at line 62 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::conv(), and vcsn::join_weightset_expansionset().
|
private |
|
inlineprivate |
Definition at line 383 of file expansionset.hh.
|
inline |
Definition at line 803 of file expansionset.hh.
|
inline |
The infiltration product of l and r.
Definition at line 450 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
Definition at line 548 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
Inplace left-division by w of res.
Definition at line 299 of file expansionset.hh.
|
inline |
Left-multiplication by w of rhs.
Definition at line 263 of file expansionset.hh.
|
inline |
Inplace left-multiplication by w of res.
Definition at line 271 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inlinestatic |
Definition at line 35 of file expansionset.hh.
|
inline |
Normalize: move the constant term to the label one.
Definition at line 143 of file expansionset.hh.
|
private |
vcsn::rat::expansionset< ExpSet >::normalize | ( | res | ) |
|
inline |
Normalize res.
There must not remain a constant-term associated to one: put it with the constant term of the expansion. I.e., turn ε⊙[⟨w⟩ε + P...] + X_p...
into ⟨w⟩ + ε⊙[P...] + X_p...
.
Definition at line 154 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::normalize().
|
inline |
Normalize when there is no label one: identity.
Definition at line 173 of file expansionset.hh.
|
inline |
The one.
Definition at line 235 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
The polynomialset.
Definition at line 68 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::conv().
|
inline |
Print this expansion.
Definition at line 108 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::print_().
|
inline |
Print this valueset.
Definition at line 80 of file expansionset.hh.
|
inline |
The expansionset for tape Tape.
Definition at line 610 of file expansionset.hh.
|
inline |
Project a multitape expansion.
Definition at line 741 of file expansionset.hh.
|
inline |
Right-multiplication of lhs by w.
Definition at line 280 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
In place right multiplication by an expression.
Definition at line 291 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
The shuffle product of de and df.
d(E) : F + E : d(F)
Definition at line 436 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inlineprivate |
The shuffle product of l and r.
Definition at line 402 of file expansionset.hh.
|
inlinestatic |
The static name.
Definition at line 54 of file expansionset.hh.
|
inline |
Transpose an expansion. The firsts must be reduced to one.
Definition at line 535 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
inline |
The tuplization of single-tape expansions into a multitape expansion.
Another implementation is possible, based on the following two-tape example taking e0 and e1, two single-tape expansions:
auto res = zero(); res.constant = ws_.mul(e0.constant, e1.constant); for (const auto& p0: e0.polynomials) for (const auto& p1: e1.polynomials) { auto l = label_t{p0.first, p1.first}; ps_.add_here(res.polynomials[l], ps_.tuple(p0.second, p1.second)); } if (!ws_.is_zero(e0.constant)) { auto rs0 = detail::project<0>(rs_); using p0_t = typename polynomialset_t::template project_t<0>; auto p0 = p0_t{{rs0.one(), e0.constant}}; for (const auto& p1: e1.polynomials) { auto l = label_t{detail::label_one(*rs0.labelset()), p1.first}; ps_.add_here(res.polynomials[l], ps_.tuple(p0, p1.second)); } } if (!ws_.is_zero(e1.constant)) { auto rs1 = detail::project<1>(rs_); using p1_t = typename polynomialset_t::template project_t<1>; auto p1 = p1_t{{rs1.one(), e1.constant}}; for (const auto& p0: e0.polynomials) { auto l = label_t{p0.first, detail::label_one(*rs1.labelset())}; ps_.add_here(res.polynomials[l], ps_.tuple(p0.second, p1)); } } return res;
The first part, the two nested for-loops that deal with the polynomial part of the expansions, is easy to scale to variadic tuples (that's a Cartesian product). The second part, the two if's and loop that deal with the constant terms, is more tricky.
Rather than making the code more complex, since the constant part of the expansions is just the weight of the unit polynomial for the unit label, let's denormalize the expansions, let the general laws apply, and then normalize the result.
Definition at line 732 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< ExpSet >::visit_tuple< bool, Dummy >::work_().
|
inline |
The zero.
Definition at line 229 of file expansionset.hh.
Referenced by vcsn::rat::to_expansion_visitor< expressionset_t >::operator()(), and vcsn::rat::to_expansion_visitor< expressionset_t >::VCSN_RAT_VISIT().
|
private |
Definition at line 361 of file expansionset.hh.
|
private |
Definition at line 366 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::denormalize(), and vcsn::rat::expansionset< expressionset_t >::normalize().
|
private |
Shorthand to the labelset.
Definition at line 824 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::denormalize_(), and vcsn::rat::expansionset< expressionset_t >::normalize_().
|
private |
The polynomialset for the polynomials.
Definition at line 828 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::denormalize_(), and vcsn::rat::expansionset< expressionset_t >::polynomialset().
|
private |
Definition at line 369 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::normalize_(), and vcsn::rat::expansionset< expressionset_t >::sname().
|
private |
The expressionset used for the expressions.
Definition at line 822 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::context(), vcsn::rat::expansionset< expressionset_t >::expressionset(), and vcsn::rat::expansionset< expressionset_t >::normalize_().
|
private |
Definition at line 357 of file expansionset.hh.
|
private |
Shorthand to the weightset.
Definition at line 826 of file expansionset.hh.
Referenced by vcsn::rat::expansionset< expressionset_t >::denormalize_(), and vcsn::rat::expansionset< expressionset_t >::normalize_().