14template <
typename Key>
31template <
typename Key>
48template <
typename Key>
51 if (
p ==
nullptr)
return;
60template <
typename Key>
69template <
typename Key>
76template <
typename Key>
83 bool one_element =
true;
95 (*p)->header = (*p)->left = (*p)->right = *
p;
97 else if ((*p)->var < insert_var)
100 mi_node *header_node, *zero_node;
104 header_node->
left = header_node->
right = zero_node;
105 (*p)->
down() = zero_node;
107 zero_node->
right = header_node;
110 if ((*p)->var > insert_var)
112 insert_var = (*p)->var;
117 insert_exp = i.exponent();
123 if (q->
exp != insert_exp)
130 insert_var, insert_exp,
static_cast<mi_node *
>(
nullptr));
136 insert_node =
new_mi_node(insert_var, insert_exp, k);
156template <
typename Key>
162 if (mi ==
nullptr)
return false;
172 if ((
p =
p->down()) ==
nullptr)
return false;
176 if (
p->exp > exp[
p->var])
178 if ((
p =
p->header->down()) ==
nullptr)
return false;
192template <
typename Key>
195 std::vector<Key>& result_k
206 if ((
p =
p->down()) ==
nullptr)
return;
210 if (
p->exp > exp[
p->var])
212 if ((
p =
p->header->down()) ==
nullptr)
return;
218 result_k.push_back(
p->key());
225template <
typename Key>
230 int nvars = topvar + 1;
231 if (*m > 0 && m[1] >= nvars) nvars =
static_cast<int>(m[1] + 1);
245 int nparts =
static_cast<int>(*m++);
246 for (
int i = nparts; i > 0; i--, m += 2)
252template <
typename Key>
256 int nparts =
static_cast<int>(*m++);
257 for (
int i = nparts; i > 0; i--, m += 2)
263template <
typename Key>
268 if (comp >=
mis.size())
return false;
270 if (mi ==
nullptr)
return false;
279template <
typename Key>
283 std::vector<Key> & result_k)
const
285 if (comp >=
mis.size())
return;
287 if (mi ==
nullptr)
return;
295template <
typename Key>
302 long comp = M->get_component(m);
303 if (comp >=
mis.size())
return false;
305 if (mi ==
nullptr)
return false;
306 M->to_expvector(m,
exp0, comp);
310template <
typename Key>
314 std::vector<Key> & result_k)
const
317 if (comp >=
mis.size())
return;
319 if (mi ==
nullptr)
return;
324template <
typename Key>
329 while (comp >=
mis.size())
mis.push_back(
nullptr);
337template <
typename Key>
350template <
typename Key>
365template <
typename Key>
385template <
typename Key>
392 assert(
p->left !=
nullptr);
393 assert(
p->right !=
nullptr);
394 assert(
p->left->right ==
p);
395 assert(
p->right->left ==
p);
398 for (i = 1; i <=
indent; i++) o <<
' ';
399 o <<
p->var <<
' ' <<
p->exp;
404 if (disp) o <<
' ' <<
p->key();
406 else if (
p ==
p->header)
413template <
typename Key>
431template <
typename Key>
440 if (i !=
nullptr)
do_tree(i, 0, 0, disp);
449template <
typename Key>
460 assert(
p !=
nullptr);
462 if (up !=
nullptr) assert(
p->var < up->var);
463 assert(
p->header ==
p);
465 assert(
p->down() == up);
466 assert(
p->left !=
nullptr);
467 assert(
p->right !=
nullptr);
471 for (q =
p->left; q !=
p; q = q->
left)
473 assert(q->
left !=
nullptr);
474 assert(q->
right !=
nullptr);
478 assert(q->
var ==
p->var);
485 for (q =
p->right; q !=
p; q = q->
right)
493template <
typename Key>
499 if (i !=
nullptr) nfound +=
debug_check(i,
nullptr);
501 assert(
count == nfound);
504template <
typename Key>
507 o <<
"F4MonomialLookupTableT (";
508 o <<
count <<
" entries)\n";
514 if ((++a) % 15 == 0) o <<
newline;
515 o <<
p->key() <<
" ";
521 std::vector<int> & result_minimals)
523 std::vector<std::pair<int, int>> degs_and_indices;
525 for (
auto& b : elems)
528 degs_and_indices.push_back(std::make_pair(deg, count));
531 std::stable_sort(degs_and_indices.begin(), degs_and_indices.end());
534 for (
auto p : degs_and_indices)
540 result_minimals.push_back(
p.second);
Append-only GC-backed byte buffer used throughout the engine for text output.
static Exponent simple_degree(ConstExponents m)
void reset_expvector(const_varpower_monomial m)
mi_node * next(mi_node *p) const
void update_expvector(int topvar, const_varpower_monomial m)
void text_out(buffer &o) const
bool find_one_divisor_packed(const MonomialInfo *M, const_packed_monomial m, Key &result_k) const
int debug_check(mi_node *p, const mi_node *up) const
void do_node(mi_node *p, int indent, int disp) const
~F4MonomialLookupTableT()
bool insert_vp(long comp, const_varpower_monomial m, Key &k)
void do_tree(mi_node *p, int depth, int indent, int disp) const
bool find_one_divisor1(mi_node *mi, const_ntuple_monomial exp, Key &result_k) const
mi_node * new_mi_node(varpower_word v, varpower_word e, mi_node *d)
void debug_out(int disp=1) const
F4MonomialLookupTableT(int nvars)
void insert_minimal_vp(long comp, const_varpower_monomial m, Key k)
void find_all_divisors_vp(long comp, const_varpower_monomial m, std::vector< Key > &result_k) const
void delete_mi_node(mi_node *p)
std::vector< mi_node * > mis
mi_node * prev(mi_node *p) const
void find_all_divisors1(mi_node *mi, const_ntuple_monomial exp, std::vector< Key > &result_k) const
void find_all_divisors_packed(const MonomialInfo *M, const_packed_monomial m, std::vector< Key > &result_k) const
void insert1(mi_node *&p, const_varpower_monomial m, Key k)
bool find_one_divisor_vp(long comp, const_varpower_monomial m, Key &result_k) const
bool to_expvector(const_packed_monomial m, ntuple_monomial result, long &result_comp) const
long get_component(const_packed_monomial m) const
Per-ring monomial layout / encoding helper used by F4GB.
void minimalize_varpower_monomials(const std::vector< varpower_monomial > &elems, std::vector< int > &result_minimals)
F4MonomialLookupTableT<Key> — monomial-ideal trie for divisor lookup.
VALGRIND_MAKE_MEM_DEFINED & result(result)
Engine-to-interpreter type vocabulary across the C++ / .dd boundary.
const monomial_word * const_packed_monomial
ntuple_monomials::Exponent ntuple_word
const ntuple_word * const_ntuple_monomial
void insert_to_left(mi_node *q)
enum F4MonomialLookupTableT::mi_node::@106101245262356146223070047151024177106047314172 tag
void emit_line(const char *s)
Text-formatting helpers layered on buffer: bignum print, line wrapping, M2_gbTrace-gated emit.
const varpower_word * const_varpower_monomial
varpower_monomials::Exponent varpower_word
ExponentListIterator< long, false > index_varpower_monomial
F4's (variable, exponent) sparse-monomial ExponentList specialisation (legacy).