basic.cpp
1 #include <symengine/printers.h>
2 #include <symengine/subs.h>
3 
4 namespace SymEngine
5 {
6 
7 int Basic::__cmp__(const Basic &o) const
8 {
9  auto a = this->get_type_code();
10  auto b = o.get_type_code();
11  if (a == b) {
12  return this->compare(o);
13  } else {
14  // We return the order given by the numerical value of the TypeID enum
15  // type.
16  // The types don't need to be ordered in any given way, they just need
17  // to be ordered.
18  return a < b ? -1 : 1;
19  }
20 }
21 
23 {
24  return str(*this);
25 }
26 
27 RCP<const Basic> Basic::subs(const map_basic_basic &subs_dict) const
28 {
29  return SymEngine::subs(this->rcp_from_this(), subs_dict);
30 }
31 
32 RCP<const Basic> Basic::xreplace(const map_basic_basic &xreplace_dict) const
33 {
34  return SymEngine::xreplace(this->rcp_from_this(), xreplace_dict);
35 }
36 
37 const char *get_version()
38 {
39  return SYMENGINE_VERSION;
40 }
41 
42 bool is_a_Atom(const Basic &b)
43 {
44  return is_a_Number(b) or is_a<Symbol>(b) or is_a<Constant>(b);
45 }
46 
47 } // namespace SymEngine
The lowest unit of symbolic representation.
Definition: basic.h:95
RCP< const Basic > subs(const map_basic_basic &subs_dict) const
Substitutes 'subs_dict' into 'self'.
Definition: basic.cpp:27
std::string __str__() const
Definition: basic.cpp:22
int __cmp__(const Basic &o) const
Comparison operator.
Definition: basic.cpp:7
virtual int compare(const Basic &o) const =0
RCP< Basic > rcp_from_this()
Get RCP<T> pointer to self (it will cast the pointer to T)
Main namespace for SymEngine package.
Definition: add.cpp:19
bool is_a_Number(const Basic &b)
Definition: number.h:130
bool is_a_Atom(const Basic &b)
Returns true if b is an atom. i.e. b.get_args returns an empty vector.
Definition: basic.cpp:42
RCP< const Basic > xreplace(const RCP< const Basic > &x, const map_basic_basic &subs_dict, bool cache=true)
Mappings in the subs_dict are applied to the expression tree of x
Definition: subs.h:299