Loading...
Searching...
No Matches
SymEngine::MExprPoly Class Reference
+ Inheritance diagram for SymEngine::MExprPoly:
+ Collaboration diagram for SymEngine::MExprPoly:

Public Member Functions

 MExprPoly (const set_basic &vars, MExprDict &&dict)
 
void accept (Visitor &v) const override
 
void accept (EvalRealDoubleVisitorFinal &v) const override
 
hash_t __hash__ () const override
 
RCP< const Basicas_symbolic () const
 
Expression eval (std::map< RCP< const Basic >, Expression, RCPBasicKeyLess > &vals) const
 
- Public Member Functions inherited from SymEngine::MSymEnginePoly< MExprDict, MExprPoly >
 MSymEnginePoly (const set_basic &vars, MExprDict &&dict)
 
int compare (const Basic &o) const override
 
vec_basic get_args () const override
 Returns the list of arguments.
 
const MExprDictget_poly () const
 
const set_basicget_vars () const
 
bool __eq__ (const Basic &o) const override
 Test equality.
 
- 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
 
virtual bool __eq__ (const Basic &o) const =0
 Test equality.
 
bool __neq__ (const Basic &o) const
 true if this is not equal to o.
 
int __cmp__ (const Basic &o) const
 Comparison operator.
 
virtual int compare (const Basic &o) const =0
 
std::string __str__ () const
 
std::string dumps () const
 Returns a string of the instance serialized.
 
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 vec_basic get_args () const =0
 Returns the list of arguments.
 
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 Attributes

static const TypeID type_code_id = SYMENGINE_MEXPRPOLY
 

Additional Inherited Members

- Public Types inherited from SymEngine::MSymEnginePoly< MExprDict, MExprPoly >
typedef MExprDict container_type
 
typedef Container::coef_type coef_type
 
- Static Public Member Functions inherited from SymEngine::MSymEnginePoly< MExprDict, MExprPoly >
static RCP< const MExprPolyfrom_container (const set_basic &vars, MExprDict &&d)
 
static enable_if_t< is_a_UPoly< FromPoly >::value, RCP< const MExprPoly > > from_poly (const FromPoly &p)
 
static RCP< const MExprPolyfrom_dict (const vec_basic &v, typename Container::dict_type &&d)
 
static MExprDict container_from_dict (const set_basic &s, typename Container::dict_type &&d)
 
- Static Public Member Functions inherited from SymEngine::Basic
static RCP< const Basicloads (const std::string &)
 Creates an instance of a serialized string.
 
- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Detailed Description

Definition at line 454 of file msymenginepoly.h.

Constructor & Destructor Documentation

◆ MExprPoly()

SymEngine::MExprPoly::MExprPoly ( const set_basic vars,
MExprDict &&  dict 
)
inline

Definition at line 457 of file msymenginepoly.h.

458 : MSymEnginePoly(vars, std::move(dict)){SYMENGINE_ASSIGN_TYPEID()}
T move(T... args)

Member Function Documentation

◆ __hash__()

hash_t SymEngine::MExprPoly::__hash__ ( ) const
overridevirtual

Calculates the hash of the given SymEngine class. Use Basic.hash() which gives a cached version of the hash.

Returns
64-bit integer value for the hash

Implements SymEngine::Basic.

Definition at line 70 of file msymenginepoly.cpp.

71{
72 hash_t seed = SYMENGINE_MEXPRPOLY;
73 for (auto var : get_vars())
74 hash_combine<std::string>(seed, var->__str__());
75
76 for (auto &p : get_poly().dict_) {
77 hash_t t = vec_hash<vec_int>()(p.first);
78 hash_combine<Basic>(t, *(p.second.get_basic()));
79 seed ^= t;
80 }
81 return seed;
82}

◆ accept() [1/2]

void SymEngine::MExprPoly::accept ( EvalRealDoubleVisitorFinal v) const
overridevirtual

Implements SymEngine::Basic.

◆ accept() [2/2]

void SymEngine::MExprPoly::accept ( Visitor v) const
overridevirtual

Implements SymEngine::Basic.

◆ as_symbolic()

RCP< const Basic > SymEngine::MExprPoly::as_symbolic ( ) const

Definition at line 54 of file msymenginepoly.cpp.

55{
56 vec_basic args;
57 for (const auto &p : get_poly().dict_) {
58 RCP<const Basic> res = (p.second.get_basic());
59 int whichvar = 0;
60 for (auto sym : get_vars()) {
61 if (0 != p.first[whichvar])
62 res = SymEngine::mul(res, pow(sym, integer(p.first[whichvar])));
63 whichvar++;
64 }
65 args.push_back(res);
66 }
67 return SymEngine::add(args);
68}
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
Definition: add.cpp:425
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)
Definition: integer.h:197
T pow(T... args)

◆ eval()

Expression SymEngine::MExprPoly::eval ( std::map< RCP< const Basic >, Expression, RCPBasicKeyLess > &  vals) const

Definition at line 84 of file msymenginepoly.cpp.

86{
87 // TODO : handle missing values
88 Expression ans(0);
89 for (auto bucket : get_poly().dict_) {
90 Expression term = bucket.second;
91 unsigned int whichvar = 0;
92 for (auto sym : get_vars()) {
93 term *= pow(vals.find(sym)->second, bucket.first[whichvar]);
94 whichvar++;
95 }
96 ans += term;
97 }
98 return ans;
99}
T find(T... args)

Field Documentation

◆ type_code_id

const TypeID SymEngine::MExprPoly::type_code_id = SYMENGINE_MEXPRPOLY
static

Type_code_id shared by all instances

Definition at line 460 of file msymenginepoly.h.


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