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

◆ construct_pairs()

int F4SPairSet::construct_pairs ( bool remove_disjoints)
private

Definition at line 246 of file f4-spairs.cpp.

247{
248 if (gb.size() == 0) return 0;
249
250 VP.reset();
251 PS.reset();
252 gbelem *me = gb[gb.size() - 1];
253 int me_component = static_cast<int>(M->get_component(me->f.monoms));
254
255 std::vector<std::vector<pre_spair *>> bins;
256
257 mtbb::tick_count t0 {mtbb::tick_count::now()};
258
259 // Loop through each element of gb, and create the pre_spair
260 for (int i = 0; i < gb.size() - 1; i++)
261 {
262 if (gb[i]->minlevel == ELEM_NON_MIN_GB) continue;
263 if (me_component != M->get_component(gb[i]->f.monoms)) continue;
264 pre_spair *p = create_pre_spair(i);
265 insert_pre_spair(bins, p);
266 }
267
268 mtbb::tick_count t1 {mtbb::tick_count::now()};
269 mPrePairsSeconds += (t1-t0).seconds();
270
272 // Now minimalize the set //
274 MonomialLookupTable *montab = new MonomialLookupTable(M->n_vars());
275
276 PreSPairSorter C;
277 int n_new_pairs = 0;
278 for (int i = 0; i < bins.size(); i++)
279 {
280 if (bins[i].size() == 0) continue;
281 // First sort the monomials of this degree
282
283 std::stable_sort(bins[i].begin(), bins[i].end(), C);
284
285 // Loop through each degree and potentially insert...
286 auto first = bins[i].begin();
287 auto next = first;
288 auto end = bins[i].end();
289 for (; first != end; first = next)
290 {
291 next = first + 1;
292 pre_spair *chosen = *first;
293 while (next != end)
294 {
295 pre_spair *p = *next;
296 if (!varpower_monomials::is_equal(chosen->quot, p->quot)) break;
297 next++;
298 }
299 /* At this point: [first,next) is the range of equal monomials */
300
301 int32_t junk;
302 bool inideal = montab->find_one_divisor_vp(0, chosen->quot, junk);
303 if (!inideal)
304 {
305 // MES: Maybe choose another of the equal monomials...
306 montab->insert_minimal_vp(0, chosen->quot, 0);
307 // The following condition is that gcd is not one
308 if (!remove_disjoints || !chosen->are_disjoint)
309 {
310 insert_spair(chosen, INTSIZE(gb) - 1);
311 n_new_pairs++;
312 }
313 }
314 }
315 }
316 delete montab;
317 mtbb::tick_count t2 {mtbb::tick_count::now()};
318 mMinimizePairsSeconds += (t2-t1).seconds();
319
320 return n_new_pairs;
321}
static bool is_equal(ConstExponents a, ConstExponents b)
void insert_minimal_vp(long comp, const_varpower_monomial m, Key k)
bool find_one_divisor_vp(long comp, const_varpower_monomial m, Key &result_k) const
const gb_array & gb
double mPrePairsSeconds
void insert_spair(pre_spair *p, int me)
Definition f4-spairs.cpp:42
const MonomialInfo * M
F4MemoryBlock< varpower_word > VP
double mMinimizePairsSeconds
F4MemoryBlock< pre_spair > PS
pre_spair * create_pre_spair(int i)
void insert_pre_spair(std::vector< std::vector< pre_spair * > > &bins, pre_spair *p)
F4MonomialLookupTableT< int32_t > MonomialLookupTable
Definition f4-types.hpp:357
@ ELEM_NON_MIN_GB
Definition f4-types.hpp:77
int p
TermIterator< Nterm > begin(Nterm *ptr)
Definition ringelem.cpp:4
TermIterator< Nterm > end(Nterm *)
Definition ringelem.cpp:5
monomial_word * monoms
Definition f4-types.hpp:110
GBF4Polynomial f
Definition f4-types.hpp:139
bool are_disjoint
Definition f4-types.hpp:120
varpower_monomial quot
Definition f4-types.hpp:118
#define INTSIZE(a)
Definition style.hpp:37
double seconds(DurationType time_diff)
Definition timing.hpp:59

References pre_spair::are_disjoint, begin(), create_pre_spair(), ELEM_NON_MIN_GB, end(), gbelem::f, F4MonomialLookupTableT< Key >::find_one_divisor_vp(), gb, F4MonomialLookupTableT< Key >::insert_minimal_vp(), insert_pre_spair(), insert_spair(), INTSIZE, ExponentList< long, false >::is_equal(), M, mMinimizePairsSeconds, GBF4Polynomial::monoms, mPrePairsSeconds, p, PS, pre_spair::quot, seconds(), and VP.

Referenced by find_new_pairs().