mul.h
Go to the documentation of this file.
1 
6 #ifndef SYMENGINE_MUL_H
7 #define SYMENGINE_MUL_H
8 
9 #include <symengine/basic.h>
10 
11 namespace SymEngine
12 {
13 
73 class Mul : public Basic
74 {
75 private:
76  RCP<const Number> coef_;
79 
80 public:
81  IMPLEMENT_TYPEID(SYMENGINE_MUL)
84  Mul(const RCP<const Number> &coef, map_basic_basic &&dict);
86  hash_t __hash__() const override;
91  bool __eq__(const Basic &o) const override;
92  int compare(const Basic &o) const override;
93 
94  // Performs canonicalization first:
96  static RCP<const Basic> from_dict(const RCP<const Number> &coef,
97  map_basic_basic &&d);
99  static void dict_add_term(map_basic_basic &d, const RCP<const Basic> &exp,
100  const RCP<const Basic> &t);
101  static void dict_add_term_new(const Ptr<RCP<const Number>> &coef,
102  map_basic_basic &d,
103  const RCP<const Basic> &exp,
104  const RCP<const Basic> &t);
106  static void as_base_exp(const RCP<const Basic> &self,
107  const Ptr<RCP<const Basic>> &exp,
108  const Ptr<RCP<const Basic>> &base);
110 
113  void as_two_terms(const Ptr<RCP<const Basic>> &a,
114  const Ptr<RCP<const Basic>> &b) const;
116  void power_num(const Ptr<RCP<const Number>> &coef, map_basic_basic &d,
117  const RCP<const Number> &exp) const;
118 
120  bool is_canonical(const RCP<const Number> &coef,
121  const map_basic_basic &dict) const;
122 
123  vec_basic get_args() const override;
124 
125  inline const RCP<const Number> &get_coef() const
126  {
127  return coef_;
128  }
129  inline const map_basic_basic &get_dict() const
130  {
131  return dict_;
132  }
133 };
135 RCP<const Basic> mul(const RCP<const Basic> &a, const RCP<const Basic> &b);
136 RCP<const Basic> mul(const vec_basic &a);
138 RCP<const Basic> div(const RCP<const Basic> &a, const RCP<const Basic> &b);
140 RCP<const Basic> neg(const RCP<const Basic> &a);
141 
142 } // namespace SymEngine
143 
144 #endif
The base class for SymEngine.
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
Definition: basic.h:340
The lowest unit of symbolic representation.
Definition: basic.h:97
bool is_canonical(const RCP< const Number > &coef, const map_basic_basic &dict) const
Definition: mul.cpp:17
bool __eq__(const Basic &o) const override
Definition: mul.cpp:89
int compare(const Basic &o) const override
Definition: mul.cpp:98
Mul(const RCP< const Number > &coef, map_basic_basic &&dict)
Definition: mul.cpp:10
static void as_base_exp(const RCP< const Basic > &self, const Ptr< RCP< const Basic >> &exp, const Ptr< RCP< const Basic >> &base)
Convert to a base and exponent form.
Definition: mul.cpp:320
static void dict_add_term(map_basic_basic &d, const RCP< const Basic > &exp, const RCP< const Basic > &t)
Add terms to dict.
Definition: mul.cpp:150
void as_two_terms(const Ptr< RCP< const Basic >> &a, const Ptr< RCP< const Basic >> &b) const
Rewrite as 2 terms.
Definition: mul.cpp:309
static RCP< const Basic > from_dict(const RCP< const Number > &coef, map_basic_basic &&d)
Create a Mul from a dict.
Definition: mul.cpp:115
void power_num(const Ptr< RCP< const Number >> &coef, map_basic_basic &d, const RCP< const Number > &exp) const
Power all terms with the exponent exp
Definition: mul.cpp:448
vec_basic get_args() const override
Returns the list of arguments.
Definition: mul.cpp:507
map_basic_basic dict_
The coefficient (e.g. 2 in 2*x*y)
Definition: mul.h:78
hash_t __hash__() const override
Definition: mul.cpp:78
Main namespace for SymEngine package.
Definition: add.cpp:19
RCP< const Basic > div(const RCP< const Basic > &a, const RCP< const Basic > &b)
Division.
Definition: mul.cpp:431
RCP< const Basic > exp(const RCP< const Basic > &x)
Returns the natural exponential function E**x = pow(E, x)
Definition: pow.cpp:271
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352
RCP< const Basic > neg(const RCP< const Basic > &a)
Negation.
Definition: mul.cpp:443