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

Public Types

typedef Expression coef_type
 
- Public Types inherited from SymEngine::USymEnginePoly< UExprDict, UExprPolyBase, UExprPoly >
using Cf = typename UExprPolyBase< UExprDict, UExprPoly >::coef_type
 
using Key = typename Container::key_type
 
typedef std::map< Key, Cf >::const_iterator iterator
 
typedef std::map< Key, Cf >::const_reverse_iterator r_iterator
 

Public Member Functions

void accept (Visitor &v) const override
 
void accept (EvalRealDoubleVisitorFinal &v) const override
 
 UExprPoly (const RCP< const Basic > &var, UExprDict &&dict)
 Constructor of UExprPoly class.
 
hash_t __hash__ () const override
 
Expression max_coef () const
 
Expression eval (const Expression &x) const
 Evaluates the UExprPoly at value x.
 
bool is_zero () const
 
bool is_one () const
 
bool is_minus_one () const
 
bool is_integer () const
 
bool is_symbol () const
 
bool is_mul () const
 
bool is_pow () const
 
- Public Member Functions inherited from SymEngine::USymEnginePoly< UExprDict, UExprPolyBase, UExprPoly >
 USymEnginePoly (const RCP< const Basic > &var, UExprDict &&dict)
 
int compare (const Basic &o) const
 
bool is_canonical (const UExprDict &dict) const
 
Cf eval (const Cf &x) const
 
const std::map< Key, Cf > & get_dict () const
 
Cf get_coeff (Key x) const
 
iterator begin () const
 
iterator end () const
 
r_iterator obegin () const
 
r_iterator oend () const
 
int size () const
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_UEXPRPOLY
 

Additional Inherited Members

- Static Public Member Functions inherited from SymEngine::USymEnginePoly< UExprDict, UExprPolyBase, UExprPoly >
static RCP< const UExprPolyfrom_vec (const RCP< const Basic > &var, const std::vector< Cf > &v)
 
static UExprDict container_from_dict (const RCP< const Basic > &var, std::map< Key, Cf > &&d)
 
static enable_if_t< is_a_UPoly< FromPoly >::value, RCP< const UExprPoly > > from_poly (const FromPoly &p)
 

Detailed Description

Definition at line 160 of file uexprpoly.h.

Member Typedef Documentation

◆ coef_type

Definition at line 169 of file uexprpoly.h.

Constructor & Destructor Documentation

◆ UExprPoly()

SymEngine::UExprPoly::UExprPoly ( const RCP< const Basic > &  var,
UExprDict &&  dict 
)

Constructor of UExprPoly class.

Definition at line 6 of file uexprpoly.cpp.

7 : USymEnginePoly(
8 var, std::move(dict)){SYMENGINE_ASSIGN_TYPEID()
9 SYMENGINE_ASSERT(is_canonical(get_poly()))}
T move(T... args)

Member Function Documentation

◆ __hash__()

hash_t SymEngine::UExprPoly::__hash__ ( ) const
override

Definition at line 11 of file uexprpoly.cpp.

12{
13 hash_t seed = SYMENGINE_UEXPRPOLY;
14
15 seed += get_var()->hash();
16 for (const auto &it : get_poly().dict_) {
17 hash_t temp = SYMENGINE_UEXPRPOLY;
18 hash_combine<unsigned int>(temp, it.first);
19 hash_combine<Basic>(temp, *(it.second.get_basic()));
20 seed += temp;
21 }
22 return seed;
23}

◆ eval()

Expression SymEngine::UExprPoly::eval ( const Expression x) const

Evaluates the UExprPoly at value x.

Definition at line 34 of file uexprpoly.cpp.

35{
36 Expression ans = 0;
37 for (const auto &p : get_poly().get_dict()) {
38 Expression temp;
39 temp = pow(x, Expression(p.first));
40 ans += p.second * temp;
41 }
42 return ans;
43}
T pow(T... args)

◆ is_integer()

bool SymEngine::UExprPoly::is_integer ( ) const
Returns
true if integer

Definition at line 63 of file uexprpoly.cpp.

64{
65 if (get_poly().empty())
66 return true;
67 return get_poly().size() == 1 and get_poly().get_dict().begin()->first == 0;
68}

◆ is_minus_one()

bool SymEngine::UExprPoly::is_minus_one ( ) const
Returns
true if -1

Definition at line 56 of file uexprpoly.cpp.

57{
58 return get_poly().size() == 1
59 and get_poly().get_dict().begin()->second == -1
60 and get_poly().get_dict().begin()->first == 0;
61}

◆ is_mul()

bool SymEngine::UExprPoly::is_mul ( ) const
Returns
true if mul

Definition at line 76 of file uexprpoly.cpp.

77{
78 return get_poly().size() == 1 and get_poly().get_dict().begin()->first != 0
79 and get_poly().get_dict().begin()->second != 1
80 and get_poly().get_dict().begin()->second != 0;
81}

◆ is_one()

bool SymEngine::UExprPoly::is_one ( ) const
Returns
true if 1

Definition at line 50 of file uexprpoly.cpp.

51{
52 return get_poly().size() == 1 and get_poly().get_dict().begin()->second == 1
53 and get_poly().get_dict().begin()->first == 0;
54}

◆ is_pow()

bool SymEngine::UExprPoly::is_pow ( ) const
Returns
true if pow

Definition at line 83 of file uexprpoly.cpp.

84{
85 return get_poly().size() == 1 and get_poly().get_dict().begin()->second == 1
86 and get_poly().get_dict().begin()->first != 1
87 and get_poly().get_dict().begin()->first != 0;
88}

◆ is_symbol()

bool SymEngine::UExprPoly::is_symbol ( ) const
Returns
true if symbol

Definition at line 70 of file uexprpoly.cpp.

71{
72 return get_poly().size() == 1 and get_poly().get_dict().begin()->first == 1
73 and get_poly().get_dict().begin()->second == 1;
74}

◆ is_zero()

bool SymEngine::UExprPoly::is_zero ( ) const
Returns
true if 0

Definition at line 45 of file uexprpoly.cpp.

46{
47 return get_poly().empty();
48}

◆ max_coef()

Expression SymEngine::UExprPoly::max_coef ( ) const

Definition at line 25 of file uexprpoly.cpp.

26{
27 Expression curr = get_poly().get_dict().begin()->second;
28 for (const auto &it : get_poly().get_dict())
29 if (curr.get_basic()->__cmp__(*it.second.get_basic()))
30 curr = it.second;
31 return curr;
32}

Field Documentation

◆ type_code_id

const TypeID SymEngine::UExprPoly::type_code_id = SYMENGINE_UEXPRPOLY
static

Type_code_id shared by all instances

Definition at line 163 of file uexprpoly.h.


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