Loading...
Searching...
No Matches
dict.cpp
2
3namespace SymEngine
4{
5
6namespace
7{
8template <class T>
9inline std::ostream &print_map(std::ostream &out, T &d)
10{
11 out << "{";
12 for (auto p = d.begin(); p != d.end(); p++) {
13 if (p != d.begin())
14 out << ", ";
15 out << (p->first) << ": " << (p->second);
16 }
17 out << "}";
18 return out;
19}
20
21template <class T>
22inline std::ostream &print_map_rcp(std::ostream &out, T &d)
23{
24 out << "{";
25 for (auto p = d.begin(); p != d.end(); p++) {
26 if (p != d.begin())
27 out << ", ";
28 out << *(p->first) << ": " << *(p->second);
29 }
30 out << "}";
31 return out;
32}
33
34template <class T>
35inline std::ostream &print_vec(std::ostream &out, T &d)
36{
37 out << "{";
38 for (auto p = d.begin(); p != d.end(); p++) {
39 if (p != d.begin())
40 out << ", ";
41 out << *p;
42 }
43 out << "}";
44 return out;
45}
46
47template <class T>
48inline std::ostream &print_vec_rcp(std::ostream &out, T &d)
49{
50 out << "{";
51 for (auto p = d.begin(); p != d.end(); p++) {
52 if (p != d.begin())
53 out << ", ";
54 out << **p;
55 }
56 out << "}";
57 return out;
58}
59
60} // anonymous namespace
61
63{
64 return SymEngine::print_map_rcp(out, d);
65}
66
68{
69 return SymEngine::print_map_rcp(out, d);
70}
71
73{
74 return SymEngine::print_map_rcp(out, d);
75}
76
79{
80 return SymEngine::print_map_rcp(out, d);
81}
82
84{
85 return SymEngine::print_vec_rcp(out, d);
86}
87
89{
90 return SymEngine::print_vec_rcp(out, d);
91}
92
94{
95 return SymEngine::print_map(out, d);
96}
97
99{
100 return SymEngine::print_map_rcp(out, d);
101}
102
103bool vec_basic_eq_perm(const vec_basic &a, const vec_basic &b)
104{
105 // Can't be equal if # of entries differ:
106 if (a.size() != b.size())
107 return false;
108 // Loop over elements in "a"
109 for (size_t i = 0; i < a.size(); i++) {
110 // Find the element a[i] in "b"
111 bool found = false;
112 for (size_t j = 0; j < a.size(); j++) {
113 if (eq(*a[i], *b[j])) {
114 found = true;
115 break;
116 }
117 }
118 // If not found, then a != b
119 if (not found)
120 return false;
121 }
122 // If all elements were found, then a == b
123 return true;
124}
125} // namespace SymEngine
Main namespace for SymEngine package.
Definition: add.cpp:19
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21
bool vec_basic_eq_perm(const vec_basic &a, const vec_basic &b)
misc functions
Definition: dict.cpp:103
std::ostream & operator<<(std::ostream &out, const SymEngine::Basic &p)
<< Operator
Definition: basic-inl.h:104
T size(T... args)