Macaulay2 Engine
Loading...
Searching...
No Matches

◆ operator()()

bool MonomialSorterObject::operator() ( int a,
int b )
inline

Definition at line 77 of file res-monomial-sorter.hpp.

78 {
79 // implements < function. In fact, a and b should not refer to objects that are == under this order.
80 // should we flag that?
81
83 bool result = false;
84 const int* m = mMonoms[a];
85 const int* n = mMonoms[b];
86 // TODO: make sure this is the order we want!!
87 int cmp = mMonoid.compare(m+2, m[1], n+2, n[1]);
88 if (cmp == LT) result = false;
89 else if (cmp == GT) result = true;
90 else
91 {
92 // compare using tie breaker
93 auto cmptie = m[0] - n[0];
94 result = (cmptie > 0);
95 }
96#if 0
97 buffer o;
98 o << "comparing: ";
99 mMonoid.elem_text_out(o, m+2);
100 o << " and ";
101 mMonoid.elem_text_out(o, n+2);
102 o << " result: " << (result ? "true" : "false");
103 emit_line(o.str());
104#endif
105 return result;
106 }
const std::vector< int * > mMonoms
char * str()
Definition buffer.hpp:72
VALGRIND_MAKE_MEM_DEFINED & result(result)
const int GT
Definition style.hpp:41
const int LT
Definition style.hpp:39
void emit_line(const char *s)
Definition text-io.cpp:47

References emit_line(), GT, LT, mMonoid, mMonoms, mNumComparisons, result(), and buffer::str().