11 #ifndef SYMENGINE_BASIC_H
12 #define SYMENGINE_BASIC_H
20 #include <unordered_map>
21 #include <unordered_set>
26 #include <type_traits>
30 #include <symengine/symengine_config.h>
31 #include <symengine/symengine_exception.h>
33 #ifdef WITH_SYMENGINE_THREAD_SAFE
44 #define SYMENGINE_INCLUDE_ALL
45 #define SYMENGINE_ENUM(type, Class) type,
46 #include "symengine/type_codes.inc"
48 #undef SYMENGINE_INCLUDE_ALL
57 #include "basic-methods.inc"
104 #if defined(WITH_SYMENGINE_THREAD_SAFE)
110 #ifdef WITH_SYMENGINE_VIRTUAL_TYPEID
111 virtual TypeID get_type_code()
const = 0;
114 inline TypeID get_type_code()
const
198 throw NotImplementedError(
"Not Implemented");
204 SYMENGINE_INCLUDE_METHODS_BASE()
206 RCP<const
Basic> diff(const RCP<const
Symbol> &x,
bool cache = true) const;
214 return static_cast<size_t>(k->hash());
221 bool operator()(
const RCP<const Basic> &x,
const RCP<const Basic> &y)
const
230 bool operator()(
const RCP<const Basic> &x,
const RCP<const Basic> &y)
const
232 hash_t xh = x->hash(), yh = y->hash();
237 return x->__cmp__(*y) == -1;
270 RCP<const Basic>
expand(
const RCP<const Basic> &
self,
bool deep =
true);
271 void as_numer_denom(
const RCP<const Basic> &x,
272 const Ptr<RCP<const Basic>> &numer,
273 const Ptr<RCP<const Basic>> &denom);
275 void as_real_imag(
const RCP<const Basic> &x,
const Ptr<RCP<const Basic>> &real,
276 const Ptr<RCP<const Basic>> &imag);
278 RCP<const Basic> rewrite_as_exp(
const RCP<const Basic> &x);
279 RCP<const Basic> rewrite_as_sin(
const RCP<const Basic> &x);
280 RCP<const Basic> rewrite_as_cos(
const RCP<const Basic> &x);
284 void cse(vec_pair &replacements, vec_basic &reduced_exprs,
285 const vec_basic &exprs);
313 const char *get_version();
325 #include "basic-inl.h"
326 #include <symengine/tribool.h>
329 #ifdef WITH_SYMENGINE_VIRTUAL_TYPEID
330 #define IMPLEMENT_TYPEID(SYMENGINE_ID) \
332 const static TypeID type_code_id = SYMENGINE_ID; \
334 virtual TypeID get_type_code() const \
336 return type_code_id; \
338 SYMENGINE_INCLUDE_METHODS_DERIVED()
340 #define IMPLEMENT_TYPEID(SYMENGINE_ID) \
342 const static TypeID type_code_id = SYMENGINE_ID; \
343 SYMENGINE_INCLUDE_METHODS_DERIVED()
346 #ifdef WITH_SYMENGINE_VIRTUAL_TYPEID
347 #define SYMENGINE_ASSIGN_TYPEID()
349 #define SYMENGINE_ASSIGN_TYPEID() this->type_code_ = type_code_id;
The lowest unit of symbolic representation.
bool __neq__(const Basic &o) const
true if this is not equal to o.
Basic(Basic &&)=delete
Delete the move constructor and assignment.
virtual RCP< const Basic > expand_as_exp() const
expands the special function in terms of exp function
virtual vec_basic get_args() const =0
Returns the list of arguments.
RCP< const Basic > subs(const map_basic_basic &subs_dict) const
Substitutes 'subs_dict' into 'self'.
std::string dumps() const
Returns a string of the instance serialized.
Basic & operator=(const Basic &)=delete
Assignment operator in continuation with above.
std::string __str__() const
static RCP< const Basic > loads(const std::string &)
Creates an instance of a serialized string.
Basic(const Basic &)=delete
Delete the copy constructor and assignment.
virtual bool __eq__(const Basic &o) const =0
Test equality.
virtual hash_t __hash__() const =0
hash_t hash_
Private variables.
int __cmp__(const Basic &o) const
Comparison operator.
virtual int compare(const Basic &o) const =0
Basic & operator=(Basic &&)=delete
Assignment operator in continuation with above.
Main namespace for SymEngine package.
bool is_a_sub(const Basic &b)
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
void hash_combine(hash_t &seed, const T &v)
bool is_a(const Basic &b)
Templatised version to check is_a type.
bool is_a_Atom(const Basic &b)
Returns true if b is an atom. i.e. b.get_args returns an empty vector.
bool is_same_type(const Basic &a, const Basic &b)
Returns true if a and b are exactly the same type T.
bool neq(const Basic &a, const Basic &b)
Checks inequality for a and b
RCP< const Basic > expand(const RCP< const Basic > &self, bool deep=true)
Expands self
std::ostream & operator<<(std::ostream &out, const SymEngine::Basic &p)
<< Operator
size_t operator()(const RCP< const Basic > &k) const
Returns the hashed value.
bool operator()(const RCP< const Basic > &x, const RCP< const Basic > &y) const
Comparison Operator ==
bool operator()(const RCP< const Basic > &x, const RCP< const Basic > &y) const
true if x < y, false otherwise