SymEngine::MSymEnginePoly< Container, Poly > Class Template Reference
+ Inheritance diagram for SymEngine::MSymEnginePoly< Container, Poly >:
+ Collaboration diagram for SymEngine::MSymEnginePoly< Container, Poly >:

Public Types

typedef Container container_type
 
typedef Container::coef_type coef_type
 

Public Member Functions

 MSymEnginePoly (const set_basic &vars, Container &&dict)
 
int compare (const Basic &o) const
 
vec_basic get_args () const
 Returns the list of arguments.
 
const Container & get_poly () const
 
const set_basicget_vars () const
 
bool __eq__ (const Basic &o) const
 Test equality. More...
 
- Public Member Functions inherited from SymEngine::Basic
TypeID get_type_code () const
 
 Basic ()
 Constructor.
 
 Basic (const Basic &)=delete
 Delete the copy constructor and assignment.
 
Basicoperator= (const Basic &)=delete
 Assignment operator in continuation with above.
 
 Basic (Basic &&)=delete
 Delete the move constructor and assignment.
 
Basicoperator= (Basic &&)=delete
 Assignment operator in continuation with above.
 
virtual hash_t __hash__ () const =0
 
hash_t hash () const
 
bool __neq__ (const Basic &o) const
 true if this is not equal to o. More...
 
int __cmp__ (const Basic &o) const
 Comparison operator.
 
std::string __str__ () const
 
RCP< const Basicsubs (const map_basic_basic &subs_dict) const
 Substitutes 'subs_dict' into 'self'.
 
RCP< const Basicxreplace (const map_basic_basic &subs_dict) const
 
virtual RCP< const Basicexpand_as_exp () const
 expands the special function in terms of exp function
 
virtual void accept (Visitor &v) const =0
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const =0
 
RCP< const Basicdiff (const RCP< const Symbol > &x, bool cache=true) const
 
- Public Member Functions inherited from SymEngine::EnableRCPFromThis< Basic >
RCP< Basicrcp_from_this ()
 Get RCP<T> pointer to self (it will cast the pointer to T)
 
RCP< const Basicrcp_from_this () const
 Get RCP<const T> pointer to self (it will cast the pointer to const T)
 
RCP< const T2 > rcp_from_this_cast () const
 Get RCP<T2> pointer to self (it will cast the pointer to T2)
 
unsigned int use_count () const
 

Static Public Member Functions

static RCP< const Poly > from_container (const set_basic &vars, Container &&d)
 
template<typename FromPoly >
static enable_if_t< is_a_UPoly< FromPoly >::value, RCP< const Poly > > from_poly (const FromPoly &p)
 
static RCP< const Poly > from_dict (const vec_basic &v, typename Container::dict_type &&d)
 
static Container container_from_dict (const set_basic &s, typename Container::dict_type &&d)
 

Private Attributes

Container poly_
 
set_basic vars_
 

Additional Inherited Members

- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Detailed Description

template<typename Container, typename Poly>
class SymEngine::MSymEnginePoly< Container, Poly >

Definition at line 313 of file msymenginepoly.h.

Member Function Documentation

◆ __eq__()

template<typename Container , typename Poly >
bool SymEngine::MSymEnginePoly< Container, Poly >::__eq__ ( const Basic o) const
inlinevirtual

Test equality.

A virtual function for testing the equality of two Basic objects

Deprecated:
Use eq(const Basic &a, const Basic &b) non-member method
Parameters
oa constant reference to object to test against
Returns
True if this is equal to o

Implements SymEngine::Basic.

Definition at line 410 of file msymenginepoly.h.

411  {
412  // TODO : fix for when vars are different, but there is an intersection
413  if (not is_a<Poly>(o))
414  return false;
415  const Poly &o_ = down_cast<const Poly &>(o);
416  // compare constants without regards to vars
417  if (1 == poly_.dict_.size() && 1 == o_.poly_.dict_.size()) {
418  if (poly_.dict_.begin()->second != o_.poly_.dict_.begin()->second)
419  return false;
420  if (poly_.dict_.begin()->first == o_.poly_.dict_.begin()->first
421  && unified_eq(vars_, o_.vars_))
422  return true;
423  typename Container::vec_type v1, v2;
424  v1.resize(vars_.size(), 0);
425  v2.resize(o_.vars_.size(), 0);
426  if (poly_.dict_.begin()->first == v1
427  || o_.poly_.dict_.begin()->first == v2)
428  return true;
429  return false;
430  } else if (0 == poly_.dict_.size() && 0 == o_.poly_.dict_.size()) {
431  return true;
432  } else {
433  return (unified_eq(vars_, o_.vars_)
434  && unified_eq(poly_.dict_, o_.poly_.dict_));
435  }
436  }
T size(T... args)

◆ compare()

template<typename Container , typename Poly >
int SymEngine::MSymEnginePoly< Container, Poly >::compare ( const Basic o) const
inlinevirtual

Returns -1, 0, 1 for this < o, this == o, this > o. This method is used when you want to sort things like x+y+z into canonical order. This function assumes that o is the same type as this. Use __cmp__ if you want general comparison.

Implements SymEngine::Basic.

Definition at line 333 of file msymenginepoly.h.

334  {
335  SYMENGINE_ASSERT(is_a<Poly>(o))
336 
337  const Poly &s = down_cast<const Poly &>(o);
338 
339  if (vars_.size() != s.vars_.size())
340  return vars_.size() < s.vars_.size() ? -1 : 1;
341  if (poly_.dict_.size() != s.poly_.dict_.size())
342  return poly_.dict_.size() < s.poly_.dict_.size() ? -1 : 1;
343 
344  int cmp = unified_compare(vars_, s.vars_);
345  if (cmp != 0)
346  return cmp;
347 
348  return unified_compare(poly_.dict_, s.poly_.dict_);
349  }
int unified_compare(const T &a, const T &b)
Definition: dict.h:205

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