7 #ifndef SYMENGINE_DICT_H
8 #define SYMENGINE_DICT_H
9 #include <symengine/mp_class.h>
14 #include <unordered_map>
16 #include <unordered_set>
28 struct RCPBasicKeyLess;
29 struct RCPIntegerKeyLess;
31 bool eq(
const Basic &,
const Basic &);
32 typedef uint64_t hash_t;
70 hash_t operator()(
const T &v)
const;
82 template <
typename T1,
typename T2,
typename T3>
83 inline void insert(T1 &m,
const T2 &first,
const T3 &second)
90 template <
class M,
typename C = std::less<
typename M::key_type>>
102 template <
bool B,
class T =
void>
105 template <
typename T,
typename U>
108 return unified_eq(a.first, b.first) and unified_eq(a.second, b.second);
111 template <typename T, typename U>
112 inline
bool unified_eq(const
std::set<T, U> &a, const
std::set<T, U> &b)
114 return ordered_eq(a, b);
117 template <
typename T,
typename U>
121 return ordered_eq(a, b);
124 template <
typename K,
typename V,
typename C>
127 return ordered_eq(a, b);
130 template <
typename K,
typename V,
typename H,
typename E>
137 template <
typename T,
typename U,
138 typename = enable_if_t<std::is_base_of<Basic, T>::value
140 inline bool unified_eq(
const RCP<const T> &a,
const RCP<const U> &b)
145 template <
typename T,
146 typename = enable_if_t<std::is_arithmetic<T>::value
148 inline bool unified_eq(
const T &a,
const T &b)
163 if (a.size() != b.size())
166 for (
const auto &p : a) {
168 auto f = b.find(p.first);
171 if (not unified_eq(p.second, f->second))
178 inline bool ordered_eq(
const T &A,
const T &B)
181 if (A.size() != B.size())
186 for (; a != A.end(); ++a, ++b) {
187 if (not unified_eq(*a, *b))
193 template <
typename T>
196 return ordered_eq(a, b);
201 template <
typename T,
202 typename = enable_if_t<std::is_arithmetic<T>::value
209 return a < b ? -1 : 1;
212 template <
typename T,
typename U,
213 typename = enable_if_t<std::is_base_of<Basic, T>::value
215 inline int unified_compare(
const RCP<const T> &a,
const RCP<const U> &b)
217 return a->__cmp__(*b);
221 inline int ordered_compare(
const T &A,
const T &B);
223 template <
typename T>
226 return ordered_compare(a, b);
229 template <
typename T,
typename U>
232 return ordered_compare(a, b);
235 template <
typename T,
typename U>
239 return ordered_compare(a, b);
242 template <
typename T,
typename U>
253 template <
typename K,
typename V,
typename C>
257 return ordered_compare(a, b);
260 template <
typename K,
typename V,
typename H,
typename E>
264 return unordered_compare(a, b);
268 inline int ordered_compare(
const T &A,
const T &B)
271 if (A.size() != B.size())
272 return A.size() < B.size() ? -1 : 1;
277 for (; a != A.end(); ++a, ++b) {
285 template <
class M,
typename C = std::less<
typename M::key_type>>
286 inline int unordered_compare(
const M &a,
const M &b)
289 if (a.size() != b.size())
290 return a.size() < b.size() ? -1 : 1;
295 for (
unsigned int i = 0; i < va.
size() && i < vb.
size(); i++) {
296 bool s = C()(va[i], vb[i]);
299 s = C()(vb[i], va[i]);
Main namespace for SymEngine package.
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
void insert(T1 &m, const T2 &first, const T3 &second)
bool vec_basic_eq_perm(const vec_basic &a, const vec_basic &b)
misc functions
int unified_compare(const T &a, const T &b)
std::ostream & operator<<(std::ostream &out, const SymEngine::Basic &p)
<< Operator
bool unordered_eq(const T &a, const T &b)