Loading...
Searching...
No Matches
tuple.cpp
1#include <symengine/tuple.h>
2#include <symengine/dict.h>
3
4namespace SymEngine
5{
6
7Tuple::Tuple(const vec_basic &container) : container_(container)
8{
9 SYMENGINE_ASSIGN_TYPEID()
10 SYMENGINE_ASSERT(Tuple::is_canonical(container_));
11}
12
13bool Tuple::is_canonical(const vec_basic &container)
14{
15 return true;
16}
17
18hash_t Tuple::__hash__() const
19{
20 hash_t seed = SYMENGINE_TUPLE;
21 for (const auto &a : container_)
22 hash_combine<Basic>(seed, *a);
23 return seed;
24}
25
26bool Tuple::__eq__(const Basic &o) const
27{
28 if (is_a<Tuple>(o)) {
29 const Tuple &other = down_cast<const Tuple &>(o);
30 return unified_eq(container_, other.container_);
31 }
32 return false;
33}
34
35int Tuple::compare(const Basic &o) const
36{
37 SYMENGINE_ASSERT(is_a<Tuple>(o))
38 const Tuple &other = down_cast<const Tuple &>(o);
39 return unified_compare(container_, other.container_);
40}
41
42RCP<const Basic> tuple(const vec_basic &arg)
43{
44 return make_rcp<const Tuple>(arg);
45}
46
47} // namespace SymEngine
The lowest unit of symbolic representation.
Definition: basic.h:97
Main namespace for SymEngine package.
Definition: add.cpp:19
int unified_compare(const T &a, const T &b)
Definition: dict.h:205