19#ifndef _monomial_collection_hpp_
20#define _monomial_collection_hpp_
63#include <memtailor/Arena.h>
69#include <unordered_set>
73template<
typename T1,
typename T2>
74std::ostream&
operator << (std::ostream& o,
const std::pair<T1,T2>&
p)
76 return o <<
"[" <<
p.first <<
"," <<
p.second <<
"]";
83 for (
const auto& elem : collection) {
84 std::cout << elem <<
' ';
86 std::cout << std::endl;
93 std::cout <<
"size: " << cont.
size() << std::endl;
94 std::cout <<
"buckets: " << cont.bucket_count() << std::endl;
95 std::cout <<
"load factor: " << cont.load_factor() << std::endl;
96 std::cout <<
"max load factor: " << cont.max_load_factor() << std::endl;
99 if (
typeid(
typename std::iterator_traits<typename T::iterator>::iterator_category)
100 ==
typeid(std::bidirectional_iterator_tag))
102 std::cout <<
"chaining style: doubly-linked" << std::endl;
106 std::cout <<
"chaining style: singly-linked" << std::endl;
110 std::cout <<
"data: " << std::endl;
111 for (
auto idx=0ul; idx != cont.bucket_count(); ++idx)
113 std::cout <<
" b[" << std::setw(2) << idx <<
"]: ";
114 for (
auto pos = cont.begin(idx); pos != cont.end(idx); ++pos)
116 std::cout << *pos <<
" ";
118 std::cout << std::endl;
219 if (e1[0] != e2[0])
return false;
220 for (
int i=2; i < e1[0]; ++i)
221 if (e1[i] != e2[i])
return false;
231 o <<
"val=" << m[1] <<
" [";
232 for (
int i=3; i<3+m[0]; ++i)
234 o <<
"comp=" << m[2] << std::endl;
266 bool keysEqual(
const ModuleMonom& e1,
const ModuleMonom& e2)
const
268 if (e1[0] != e2[0])
return false;
269 for (
int i=2; i < e1[0]; ++i)
270 if (e1[i] != e2[i])
return false;
274 std::size_t operator() (
const ModuleMonom& e)
const {
return hash(e); }
276 bool operator() (
const ModuleMonom& e1,
const ModuleMonom& e2)
const {
return keysEqual(e1,e2); }
278 void display(std::ostream& o,
const ModuleMonom& m)
const
280 o <<
"val=" << m[1] <<
" [";
281 for (
int i=3; i<3+m[0]; ++i)
283 o <<
"comp=" << m[2] << std::endl;
290template<
typename Configuration>
302 using Set = std::unordered_set<ModuleMonom, ModuleMonomHash, ModuleMonomEq>;
315 std::pair<int*, int*> mon {
mArena.allocArrayNoCon<
int>(sz) };
318 bool new_elem =
result.second;
336 std::pair<int*, int*> mon {
mArena.allocArrayNoCon<
int>(sz) };
340 int idx = (found ?
result->index() : -1);
341 mArena.freeTop(mon.first);
357 o <<
" " << m << std::endl;
ModuleMonom monomToModuleMonom(const Monom &a, int comp, std::pair< int *, int * > allocated_result)
Modern Monom / Polynomial value types shared by NC algebras and the refactored F4.
Word prefix(const Word vec, int lengthOfPrefix)
Configuration configuration() const
bool insert(Monom m, int comp)
void stats(std::ostream &o) const
std::unordered_set< ModuleMonom, ModuleMonomHash, ModuleMonomEq > Set
std::pair< int, bool > find(Monom m, int comp)
std::vector< ModuleMonom > mElements
void display(std::ostream &o) const
auto begin() const -> decltype(mElements.begin())
auto end() const -> decltype(mElements.end())
const std::vector< ModuleMonom > & uniqueMonoms() const
static int sizeOfCorrespondingModuleMonom(const Monom &m)
static int compare(const ModuleMonom &m1, const ModuleMonom &m2)
ModuleMonomDefaultConfig(const ModuleMonomDefaultConfig &C)
ModuleMonomDefaultConfig(int nvars)
std::size_t hash(const ModuleMonom &m) const
bool keysEqual(const ModuleMonom &e1, const ModuleMonom &e2) const
ModuleMonomDefaultConfigOrig(const ModuleMonomDefaultConfigOrig &C)
void display(std::ostream &o, const ModuleMonom &m) const
ModuleMonomDefaultConfigOrig(int nvars)
std::size_t operator()(const ModuleMonom &e) const
bool operator()(const ModuleMonom &a, const ModuleMonom &b) const
Equality functor on ModuleMonom, forwarding to operator==.
std::size_t operator()(const ModuleMonom &m) const
Hash functor on ModuleMonom, forwarding to ModuleMonom::hash.
Monom extended with a module component, a stored index, and a memoised hash — the value type of IntsS...
bool operator()(const ModuleMonom &a, const ModuleMonom &b) const
Strict-weak-order comparator on ModuleMonom, used by IntsSet::sort to reorder the insertion-ordered m...
VALGRIND_MAKE_MEM_DEFINED & result(result)
IntsSet< ModuleMonomDefaultConfig > ModuleMonomialSet
std::ostream & operator<<(std::ostream &o, const std::pair< T1, T2 > &p)
void printHashTableState(const T &cont)
void PRINT_ELEMENTS(const T &collection, const std::string &prefix)
Non-owning view onto a [length, degree, v1, v2, ..., vn] packed monomial in some externally managed b...
Engine-wide stylistic constants: LT / EQ / GT codes, INTSIZE, GEOHEAP_SIZE.