Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
vcsn::polynomialset< Context > Class Template Reference

Linear combination of labels: map labels to weights. More...

#include <fwd.hh>

Inheritance diagram for vcsn::polynomialset< Context >:
Collaboration diagram for vcsn::polynomialset< Context >:

Public Types

using self_type = polynomialset< Context >
 
using context_t = Context
 
using labelset_t = labelset_t_of< context_t >
 
using weightset_t = weightset_t_of< context_t >
 
using polynomialset_t = polynomialset< context_t >
 
using labelset_ptr = typename context_t::labelset_ptr
 
using weightset_ptr = typename context_t::weightset_ptr
 
using label_t = typename labelset_t::value_t
 Polynomials over labels. More...
 
using weight_t = weight_t_of< context_t >
 
using value_t = std::map< label_t, weight_t, vcsn::less< labelset_t >>
 
using monomial_t = typename value_t::value_type
 A pair <label, weight>. More...
 

Public Member Functions

 polynomialset ()=delete
 
 polynomialset (const polynomialset &)=default
 
 polynomialset (const context_t &ctx)
 
std::string vname (bool full=true) const
 The dynamic name. More...
 
const context_tcontext () const
 
const labelset_ptrlabelset () const
 
const weightset_ptrweightset () const
 
value_tdel_weight (value_t &v, const label_t &w) const
 Remove the monomial of w in v. More...
 
value_tset_weight (value_t &v, const label_t &w, const weight_t k) const
 Set the monomial of w in v to weight k. More...
 
value_tadd_here (value_t &v, const value_t &p) const
 v += p. More...
 
value_tadd_here (value_t &v, const monomial_t &p) const
 v += m. More...
 
value_tadd_here (value_t &v, const label_t &l, const weight_t k) const
 v += (l, k). More...
 
const weight_t get_weight (const value_t &v, const label_t &w) const ATTRIBUTE_PURE
 
value_t add (const value_t &l, const value_t &r) const
 The sum of polynomials l and r. More...
 
value_t mul (const value_t &l, const value_t &r) const
 The product of polynomials l and r. More...
 
value_t conjunction (const value_t &l, const value_t &r) const
 The conjunction of polynomials l and r. More...
 
weight_t scalar_product (const value_t &l, const value_t &r) const
 The sum of the weights of the common labels. More...
 
value_t star (const value_t &v) const
 The star of polynomial v. More...
 
value_t lmul (const weight_t &w, const value_t &v) const
 Left exterior product. More...
 
value_t lmul (const label_t &lhs, const value_t &v) const
 Left product by a label. More...
 
value_t rmul (const value_t &v, const weight_t &w) const
 Right exterior product. More...
 
value_t rmul (const value_t &v, const label_t &rhs) const
 Right product. More...
 
value_tldiv_here (const weight_t &w, value_t &v) const
 Left exterior division. More...
 
value_trdiv_here (value_t &v, const weight_t &w) const
 Right exterior division. More...
 
template<typename WeightSet , typename std::enable_if<!std::is_same< WeightSet, z >::value, int >::type = 0>
WeightSet::value_t norm_ (value_t &v) const
 In the general case, normalize by the first (non null) weight. More...
 
template<typename WeightSet , typename std::enable_if< std::is_same< WeightSet, z >::value, int >::type = 0>
WeightSet::value_t norm_ (value_t &v) const
 For Z, take the GCD, with the sign of the first value. More...
 
weight_t normalize_here (value_t &v) const
 Normalize v in place, and return the factor which was divided. More...
 
const value_tone () const
 
const monomial_tmonomial_one () const
 
bool is_one (const value_t &v) const ATTRIBUTE_PURE
 
const value_tzero () const
 
bool is_zero (const value_t &v) const
 
template<typename WS >
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. More...
 
template<typename C >
value_t conv (const polynomialset< C > &sps, const typename polynomialset< C >::value_t &v) const
 Convert from another polynomialset to type_t. More...
 
value_t transpose (const value_t &v) const
 
std::ostream & print_set (std::ostream &o, symbol format=symbol{"text"}) const
 
value_t conv (std::istream &i, const char sep= '+') const
 Construct from a string. More...
 
std::ostream & print (const monomial_t &m, std::ostream &out, symbol format=symbol{"text"}) const
 Print a monomial. More...
 
std::ostream & print (const value_t &v, std::ostream &out, symbol format=symbol{"text"}, const std::string &sep=" + ") const
 Print a value (a polynomial). More...
 

Static Public Member Functions

static std::string sname ()
 The static name. More...
 
static value_t rdiv (const value_t &, const value_t &)
 
static value_t ldiv (const value_t &l, const value_t &r)
 
static ATTRIBUTE_PURE bool monomial_equals (const monomial_t &lhs, const monomial_t &rhs)
 
static bool equals (const value_t &l, const value_t &r) ATTRIBUTE_PURE
 
static constexpr bool show_one ()
 
static constexpr star_status_t star_status ()
 
static value_t conv (self_type, value_t v)
 Conversion from (this and) other weightsets. More...
 
static ATTRIBUTE_PURE bool monomial_less_than (const monomial_t &lhs, const monomial_t &rhs)
 
static bool less_than (const value_t &lhs, const value_t &rhs)
 
static ATTRIBUTE_PURE size_t hash (const monomial_t &m)
 
static ATTRIBUTE_PURE size_t hash (const value_t &v)
 
static self_type make (std::istream &is)
 Build from the description in is. More...
 

Private Member Functions

std::ostream & print_weight_ (const weight_t &w, std::ostream &out, symbol format=symbol{"text"}) const
 Print a weight. More...
 
std::ostream & print_without_ranges_ (const value_t &v, std::ostream &out, symbol format=symbol{"text"}, const std::string &sep=" + ") const
 Print a polynomial value without ranges. More...
 
std::ostream & print_with_ranges_ (const value_t &v, std::ostream &out, symbol format=symbol{"text"}, const std::string &sep=" + ") const
 Print a polynomial value with ranges. More...
 
template<typename context >
std::enable_if
<!(context::is_lal||context::is_lan),
std::ostream & >::type 
print_ (const value_t &v, std::ostream &out, symbol format=symbol{"text"}, const std::string &sep=" + ") const
 Print a non-null value for neither LAL nor LAN. More...
 
template<typename Ctx >
std::enable_if< Ctx::is_lal||Ctx::is_lan,
std::ostream & >::type 
print_ (const value_t &v, std::ostream &out, symbol format=symbol{"text"}, const std::string &sep=" + ") const
 Print a non-null value for LAL or LAN. More...
 

Private Attributes

context_t ctx_
 

Static Private Attributes

static constexpr char langle = '<'
 Left marker for weight in concrete syntax. More...
 
static constexpr char rangle = '>'
 Right marker for weight in concrete syntax. More...
 

Detailed Description

template<class Context>
class vcsn::polynomialset< Context >

Linear combination of labels: map labels to weights.

Template Parameters
Contextthe LabelSet and WeightSet types.

Definition at line 32 of file fwd.hh.

Member Typedef Documentation

template<class Context>
using vcsn::polynomialset< Context >::context_t = Context

Definition at line 58 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::label_t = typename labelset_t::value_t

Polynomials over labels.

Definition at line 66 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::labelset_ptr = typename context_t::labelset_ptr

Definition at line 63 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::labelset_t = labelset_t_of<context_t>

Definition at line 59 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::monomial_t = typename value_t::value_type

A pair <label, weight>.

Definition at line 71 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::polynomialset_t = polynomialset<context_t>

Definition at line 61 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::self_type = polynomialset<Context>

Definition at line 57 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::value_t = std::map<label_t, weight_t, vcsn::less<labelset_t>>

Definition at line 69 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::weight_t = weight_t_of<context_t>

Definition at line 67 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::weightset_ptr = typename context_t::weightset_ptr

Definition at line 64 of file polynomialset.hh.

template<class Context>
using vcsn::polynomialset< Context >::weightset_t = weightset_t_of<context_t>

Definition at line 60 of file polynomialset.hh.

Constructor & Destructor Documentation

template<class Context>
vcsn::polynomialset< Context >::polynomialset ( )
delete
template<class Context>
vcsn::polynomialset< Context >::polynomialset ( const polynomialset< Context > &  )
default
template<class Context>
vcsn::polynomialset< Context >::polynomialset ( const context_t ctx)
inline

Definition at line 75 of file polynomialset.hh.

Member Function Documentation

template<class Context>
value_t vcsn::polynomialset< Context >::add ( const value_t l,
const value_t r 
) const
inline

The sum of polynomials l and r.

Definition at line 167 of file polynomialset.hh.

Referenced by vcsn::rat::split_visitor< RatExpSet >::product(), and vcsn::rat::expand_visitor< RatExpSet >::VCSN_RAT_VISIT().

template<class Context>
value_t& vcsn::polynomialset< Context >::add_here ( value_t v,
const monomial_t p 
) const
inline

v += m.

Definition at line 125 of file polynomialset.hh.

template<class Context>
value_t& vcsn::polynomialset< Context >::add_here ( value_t v,
const label_t l,
const weight_t  k 
) const
inline

v += (l, k).

Definition at line 132 of file polynomialset.hh.

template<class Context>
value_t vcsn::polynomialset< Context >::conjunction ( const value_t l,
const value_t r 
) const
inline

The conjunction of polynomials l and r.

Not valid for all the labelsets.

Definition at line 190 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::conjunction(), and vcsn::rat::derivation_visitor< RatExpSet >::VCSN_RAT_VISIT().

template<class Context>
const context_t& vcsn::polynomialset< Context >::context ( ) const
inline

Definition at line 91 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::vname().

template<class Context>
static value_t vcsn::polynomialset< Context >::conv ( self_type  ,
value_t  v 
)
inlinestatic

Conversion from (this and) other weightsets.

Definition at line 402 of file polynomialset.hh.

template<class Context>
template<typename WS >
value_t vcsn::polynomialset< Context >::conv ( const WS &  ws,
const typename WS::value_t &  v 
) const
inline

FIXME: use enable_if to prevent this from being instantiated when WS is a polynomialset.

Then use this same technique for ratexps.

Definition at line 412 of file polynomialset.hh.

template<class Context>
template<typename C >
value_t vcsn::polynomialset< Context >::conv ( const polynomialset< C > &  sps,
const typename polynomialset< C >::value_t v 
) const
inline

Convert from another polynomialset to type_t.

Definition at line 420 of file polynomialset.hh.

template<class Context>
value_t vcsn::polynomialset< Context >::conv ( std::istream &  i,
const char  sep = '+' 
) const
inline

Construct from a string.

Somewhat more general than a mere reversal of "format", in particular "a+a" is properly understood as "<2>a" in char_z.

Parameters
ithe stream to parse
septhe separator between monomials.

Definition at line 525 of file polynomialset.hh.

template<class Context>
value_t& vcsn::polynomialset< Context >::del_weight ( value_t v,
const label_t w 
) const
inline
template<class Context>
static bool vcsn::polynomialset< Context >::equals ( const value_t l,
const value_t r 
)
inlinestatic

Definition at line 349 of file polynomialset.hh.

template<class Context>
const weight_t vcsn::polynomialset< Context >::get_weight ( const value_t v,
const label_t w 
) const
inline
template<class Context>
static ATTRIBUTE_PURE size_t vcsn::polynomialset< Context >::hash ( const monomial_t m)
inlinestatic

Definition at line 464 of file polynomialset.hh.

template<class Context>
static ATTRIBUTE_PURE size_t vcsn::polynomialset< Context >::hash ( const value_t v)
inlinestatic

Definition at line 473 of file polynomialset.hh.

template<class Context>
bool vcsn::polynomialset< Context >::is_one ( const value_t v) const
inline

Definition at line 371 of file polynomialset.hh.

template<class Context>
static value_t vcsn::polynomialset< Context >::ldiv ( const value_t l,
const value_t r 
)
inlinestatic

Definition at line 285 of file polynomialset.hh.

template<class Context>
value_t& vcsn::polynomialset< Context >::ldiv_here ( const weight_t w,
value_t v 
) const
inline

Left exterior division.

Definition at line 292 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::normalize_here().

template<class Context>
static bool vcsn::polynomialset< Context >::less_than ( const value_t lhs,
const value_t rhs 
)
inlinestatic

Definition at line 446 of file polynomialset.hh.

template<class Context>
value_t vcsn::polynomialset< Context >::lmul ( const label_t lhs,
const value_t v 
) const
inline

Left product by a label.

Definition at line 244 of file polynomialset.hh.

template<class Context>
static self_type vcsn::polynomialset< Context >::make ( std::istream &  is)
inlinestatic

Build from the description in is.

Definition at line 485 of file polynomialset.hh.

template<class Context>
static ATTRIBUTE_PURE bool vcsn::polynomialset< Context >::monomial_equals ( const monomial_t lhs,
const monomial_t rhs 
)
inlinestatic

Definition at line 341 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::equals().

template<class Context>
static ATTRIBUTE_PURE bool vcsn::polynomialset< Context >::monomial_less_than ( const monomial_t lhs,
const monomial_t rhs 
)
inlinestatic

Definition at line 435 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::less_than().

template<class Context>
const monomial_t& vcsn::polynomialset< Context >::monomial_one ( ) const
inline
template<class Context>
template<typename WeightSet , typename std::enable_if<!std::is_same< WeightSet, z >::value, int >::type = 0>
WeightSet::value_t vcsn::polynomialset< Context >::norm_ ( value_t v) const
inline

In the general case, normalize by the first (non null) weight.

Definition at line 312 of file polynomialset.hh.

template<class Context>
template<typename WeightSet , typename std::enable_if< std::is_same< WeightSet, z >::value, int >::type = 0>
WeightSet::value_t vcsn::polynomialset< Context >::norm_ ( value_t v) const
inline

For Z, take the GCD, with the sign of the first value.

Definition at line 321 of file polynomialset.hh.

template<class Context>
weight_t vcsn::polynomialset< Context >::normalize_here ( value_t v) const
inline

Normalize v in place, and return the factor which was divided.

Definition at line 333 of file polynomialset.hh.

template<class Context>
std::ostream& vcsn::polynomialset< Context >::print ( const monomial_t m,
std::ostream &  out,
symbol  format = symbol{"text"} 
) const
inline

Print a monomial.

Definition at line 617 of file polynomialset.hh.

Referenced by vcsn::detail::outputter< Aut >::print_entry_().

template<class Context>
std::ostream& vcsn::polynomialset< Context >::print ( const value_t v,
std::ostream &  out,
symbol  format = symbol{"text"},
const std::string &  sep = " + " 
) const
inline

Print a value (a polynomial).

Parameters
vthe polynomial
outthe output stream
formatthe format: "text" or "latex"
septhe separator between monomials

Definition at line 637 of file polynomialset.hh.

template<class Context>
template<typename context >
std::enable_if<!(context::is_lal || context::is_lan), std::ostream&>::type vcsn::polynomialset< Context >::print_ ( const value_t v,
std::ostream &  out,
symbol  format = symbol{"text"},
const std::string &  sep = " + " 
) const
inlineprivate

Print a non-null value for neither LAL nor LAN.

Definition at line 746 of file polynomialset.hh.

template<class Context>
template<typename Ctx >
std::enable_if<Ctx::is_lal || Ctx::is_lan, std::ostream&>::type vcsn::polynomialset< Context >::print_ ( const value_t v,
std::ostream &  out,
symbol  format = symbol{"text"},
const std::string &  sep = " + " 
) const
inlineprivate

Print a non-null value for LAL or LAN.

Definition at line 757 of file polynomialset.hh.

template<class Context>
std::ostream& vcsn::polynomialset< Context >::print_set ( std::ostream &  o,
symbol  format = symbol{"text"} 
) const
inline

Definition at line 495 of file polynomialset.hh.

template<class Context>
std::ostream& vcsn::polynomialset< Context >::print_weight_ ( const weight_t w,
std::ostream &  out,
symbol  format = symbol{"text"} 
) const
inlineprivate

Print a weight.

Definition at line 653 of file polynomialset.hh.

template<class Context>
std::ostream& vcsn::polynomialset< Context >::print_with_ranges_ ( const value_t v,
std::ostream &  out,
symbol  format = symbol{"text"},
const std::string &  sep = " + " 
) const
inlineprivate

Print a polynomial value with ranges.

Definition at line 685 of file polynomialset.hh.

template<class Context>
std::ostream& vcsn::polynomialset< Context >::print_without_ranges_ ( const value_t v,
std::ostream &  out,
symbol  format = symbol{"text"},
const std::string &  sep = " + " 
) const
inlineprivate

Print a polynomial value without ranges.

Definition at line 668 of file polynomialset.hh.

template<class Context>
static value_t vcsn::polynomialset< Context >::rdiv ( const value_t ,
const value_t  
)
inlinestatic

Definition at line 279 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::ldiv().

template<class Context>
value_t& vcsn::polynomialset< Context >::rdiv_here ( value_t v,
const weight_t w 
) const
inline

Right exterior division.

Definition at line 301 of file polynomialset.hh.

template<class Context>
value_t vcsn::polynomialset< Context >::rmul ( const value_t v,
const label_t rhs 
) const
inline

Right product.

Definition at line 268 of file polynomialset.hh.

template<class Context>
weight_t vcsn::polynomialset< Context >::scalar_product ( const value_t l,
const value_t r 
) const
inline

The sum of the weights of the common labels.

Definition at line 203 of file polynomialset.hh.

template<class Context>
value_t& vcsn::polynomialset< Context >::set_weight ( value_t v,
const label_t w,
const weight_t  k 
) const
inline

Set the monomial of w in v to weight k.

Definition at line 105 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::add_here().

template<class Context>
static constexpr bool vcsn::polynomialset< Context >::show_one ( )
inlinestatic

Definition at line 394 of file polynomialset.hh.

template<class Context>
static std::string vcsn::polynomialset< Context >::sname ( )
inlinestatic

The static name.

Definition at line 80 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::conv(), and vcsn::polynomialset< ratexpset_t >::star().

template<class Context>
value_t vcsn::polynomialset< Context >::star ( const value_t v) const
inline

The star of polynomial v.

Definition at line 215 of file polynomialset.hh.

template<class Context>
static constexpr star_status_t vcsn::polynomialset< Context >::star_status ( )
inlinestatic

Definition at line 395 of file polynomialset.hh.

template<class Context>
value_t vcsn::polynomialset< Context >::transpose ( const value_t v) const
inline

Definition at line 455 of file polynomialset.hh.

template<class Context>
std::string vcsn::polynomialset< Context >::vname ( bool  full = true) const
inline

The dynamic name.

Definition at line 86 of file polynomialset.hh.

Member Data Documentation

template<class Context>
constexpr char vcsn::polynomialset< Context >::langle = '<'
staticprivate

Left marker for weight in concrete syntax.

Definition at line 769 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::conv().

template<class Context>
constexpr char vcsn::polynomialset< Context >::rangle = '>'
staticprivate

Right marker for weight in concrete syntax.

Definition at line 771 of file polynomialset.hh.

Referenced by vcsn::polynomialset< ratexpset_t >::conv().


The documentation for this class was generated from the following files: