add.h
Go to the documentation of this file.
1 
14 #ifndef SYMENGINE_ADD_H
15 #define SYMENGINE_ADD_H
16 
17 #include <symengine/basic.h>
18 
19 namespace SymEngine
20 {
21 
26 class Add : public Basic
27 {
28 private:
29  RCP<const Number> coef_;
33 
34 public:
35  IMPLEMENT_TYPEID(SYMENGINE_ADD)
36 
37 
43  Add(const RCP<const Number> &coef, umap_basic_num &&dict);
44 
50  virtual hash_t __hash__() const;
51 
58  virtual bool __eq__(const Basic &o) const;
59 
66  virtual int compare(const Basic &o) const;
67 
83  static RCP<const Basic> from_dict(const RCP<const Number> &coef,
84  umap_basic_num &&d);
93  static void dict_add_term(umap_basic_num &d, const RCP<const Number> &coef,
94  const RCP<const Basic> &t);
103  static void coef_dict_add_term(const Ptr<RCP<const Number>> &coef,
104  umap_basic_num &d,
105  const RCP<const Number> &c,
106  const RCP<const Basic> &term);
107 
114  void as_two_terms(const Ptr<RCP<const Basic>> &a,
115  const Ptr<RCP<const Basic>> &b) const;
116 
123  static void as_coef_term(const RCP<const Basic> &self,
124  const Ptr<RCP<const Number>> &coef,
125  const Ptr<RCP<const Basic>> &term);
132  bool is_canonical(const RCP<const Number> &coef,
133  const umap_basic_num &dict) const;
134 
139  virtual vec_basic get_args() const;
140 
142  inline const RCP<const Number> &get_coef() const
143  {
144  return coef_;
145  }
146 
148  inline const umap_basic_num &get_dict() const
149  {
150  return dict_;
151  }
152 };
153 
162 RCP<const Basic> add(const RCP<const Basic> &a, const RCP<const Basic> &b);
163 
171 RCP<const Basic> add(const vec_basic &a);
172 
181 RCP<const Basic> sub(const RCP<const Basic> &a, const RCP<const Basic> &b);
182 
183 } // namespace SymEngine
184 
185 #endif
The base class for SymEngine.
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
Definition: basic.h:340
The base class for representing addition in symbolic expressions.
Definition: add.h:27
virtual hash_t __hash__() const
Generates the hash representation.
Definition: add.cpp:72
umap_basic_num dict_
Definition: add.h:31
static RCP< const Basic > from_dict(const RCP< const Number > &coef, umap_basic_num &&d)
Create an appropriate instance from dictionary quickly.
Definition: add.cpp:140
RCP< const Number > coef_
Definition: add.h:29
virtual int compare(const Basic &o) const
Compares Add objects.
Definition: add.cpp:107
static void coef_dict_add_term(const Ptr< RCP< const Number >> &coef, umap_basic_num &d, const RCP< const Number > &c, const RCP< const Basic > &term)
Updates the numerical coefficient and the dictionary.
Definition: add.cpp:261
void as_two_terms(const Ptr< RCP< const Basic >> &a, const Ptr< RCP< const Basic >> &b) const
Converts the Add into a sum of two Basic objects.
Definition: add.cpp:287
bool is_canonical(const RCP< const Number > &coef, const umap_basic_num &dict) const
Checks if a given dictionary and coeffient is in cannonical form.
Definition: add.cpp:348
virtual bool __eq__(const Basic &o) const
Test equality.
Definition: add.cpp:88
const RCP< const Number > & get_coef() const
Definition: add.h:142
static void dict_add_term(umap_basic_num &d, const RCP< const Number > &coef, const RCP< const Basic > &t)
Adds a new term to the expression.
Definition: add.cpp:237
Add(const RCP< const Number > &coef, umap_basic_num &&dict)
Default constructor.
Definition: add.cpp:64
virtual vec_basic get_args() const
Returns the arguments of the Add.
Definition: add.cpp:397
static void as_coef_term(const RCP< const Basic > &self, const Ptr< RCP< const Number >> &coef, const Ptr< RCP< const Basic >> &term)
Converts a Basic self into the form of coefficient * term.
Definition: add.cpp:306
The lowest unit of symbolic representation.
Definition: basic.h:95
Main namespace for SymEngine package.
Definition: add.cpp:19
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
Definition: add.cpp:495
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
Definition: add.cpp:425