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

Public Member Functions

 MIntPoly (const set_basic &vars, MIntDict &&dict)
 
virtual void accept (Visitor &v) const
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const
 
hash_t __hash__ () const
 
RCP< const Basicas_symbolic () const
 
integer_class eval (std::map< RCP< const Basic >, integer_class, RCPBasicKeyLess > &vals) const
 
- Public Member Functions inherited from SymEngine::MSymEnginePoly< MIntDict, MIntPoly >
 MSymEnginePoly (const set_basic &vars, MIntDict &&dict)
 
int compare (const Basic &o) const
 
vec_basic get_args () const
 Returns the list of arguments. More...
 
const MIntDictget_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. More...
 
 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. More...
 
bool __neq__ (const Basic &o) const
 true if this is not equal to o. More...
 
int __cmp__ (const Basic &o) const
 Comparison operator. More...
 
virtual int compare (const Basic &o) const =0
 
std::string __str__ () const
 
std::string dumps () const
 Returns a string of the instance serialized. More...
 
RCP< const Basicsubs (const map_basic_basic &subs_dict) const
 Substitutes 'subs_dict' into 'self'. More...
 
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 More...
 
virtual vec_basic get_args () const =0
 Returns the list of arguments. More...
 
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) More...
 
RCP< const Basicrcp_from_this () const
 Get RCP<const T> pointer to self (it will cast the pointer to const T) More...
 
RCP< const T2 > rcp_from_this_cast () const
 Get RCP<T2> pointer to self (it will cast the pointer to T2) More...
 
unsigned int use_count () const
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_MINTPOLY
 

Additional Inherited Members

- Public Types inherited from SymEngine::MSymEnginePoly< MIntDict, MIntPoly >
typedef MIntDict container_type
 
typedef Container::coef_type coef_type
 
- Static Public Member Functions inherited from SymEngine::MSymEnginePoly< MIntDict, MIntPoly >
static RCP< const MIntPolyfrom_container (const set_basic &vars, MIntDict &&d)
 
static enable_if_t< is_a_UPoly< FromPoly >::value, RCP< const MIntPoly > > from_poly (const FromPoly &p)
 
static RCP< const MIntPolyfrom_dict (const vec_basic &v, typename Container::dict_type &&d)
 
static MIntDict 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. More...
 
- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Detailed Description

Definition at line 439 of file msymenginepoly.h.

Constructor & Destructor Documentation

◆ MIntPoly()

SymEngine::MIntPoly::MIntPoly ( const set_basic vars,
MIntDict &&  dict 
)
inline

Definition at line 442 of file msymenginepoly.h.

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

Member Function Documentation

◆ __hash__()

hash_t SymEngine::MIntPoly::__hash__ ( ) const
virtual

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 22 of file msymenginepoly.cpp.

23{
24 hash_t seed = SYMENGINE_MINTPOLY;
25 for (auto var : get_vars())
26 hash_combine<std::string>(seed, var->__str__());
27
28 for (auto &p : get_poly().dict_) {
29 hash_t t = vec_hash<vec_uint>()(p.first);
30 hash_combine<hash_t>(t, mp_get_si(p.second));
31 seed ^= t;
32 }
33 return seed;
34}

◆ accept() [1/2]

virtual void SymEngine::MIntPoly::accept ( EvalRealDoubleVisitorFinal v) const
virtual

Implements SymEngine::Basic.

◆ accept() [2/2]

virtual void SymEngine::MIntPoly::accept ( Visitor v) const
virtual

Implements SymEngine::Basic.

◆ as_symbolic()

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

Definition at line 6 of file msymenginepoly.cpp.

7{
8 vec_basic args;
9 for (const auto &p : get_poly().dict_) {
10 RCP<const Basic> res = integer(p.second);
11 int whichvar = 0;
12 for (auto sym : get_vars()) {
13 if (0 != p.first[whichvar])
14 res = SymEngine::mul(res, pow(sym, integer(p.first[whichvar])));
15 whichvar++;
16 }
17 args.push_back(res);
18 }
19 return SymEngine::add(args);
20}
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:200
T pow(T... args)

◆ eval()

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

Definition at line 36 of file msymenginepoly.cpp.

38{
39 // TODO : handle missing values
40 integer_class ans(0), temp, term;
41 for (auto bucket : get_poly().dict_) {
42 term = bucket.second;
43 unsigned int whichvar = 0;
44 for (auto sym : get_vars()) {
45 mp_pow_ui(temp, vals.find(sym)->second, bucket.first[whichvar]);
46 term *= temp;
47 whichvar++;
48 }
49 ans += term;
50 }
51 return ans;
52}
T find(T... args)

Field Documentation

◆ type_code_id

const TypeID SymEngine::MIntPoly::type_code_id = SYMENGINE_MINTPOLY
static

Type_code_id shared by all instances

Definition at line 445 of file msymenginepoly.h.


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