Macaulay2 Engine
Loading...
Searching...
No Matches
f4-spairs.hpp
Go to the documentation of this file.
1// Copyright 2004-2021 Michael E. Stillman
2
3#pragma once
4
44
45#include <queue> // for std::priority_queue
46#include "MemoryBlock.hpp" // for MemoryBlock
47#include "f4/f4-types.hpp" // for spair (ptr only), gb_array, pre_...
48#include "f4/memblock.hpp" // for F4MemoryBlock
49#include "f4/moninfo.hpp" // for MonomialInfo (ptr only), packed_...
50#include "f4/varpower-monomial.hpp" // for varpower_word
51
68{
69 private:
71 int deg,
72 int i,
73 int j); // CAUTION: lcm is allocated correctly, but is
74 // NOT initialized. That is the caller's responsibility!!
75
76 bool pair_not_needed(spair *p, gbelem *m);
77
79 // returns the number of pairs removed, based on the element gb[gb.size()-1]
80
82
83 int construct_pairs(bool remove_disjoints);
84
85 public:
86#if defined(WITH_TBB)
87 F4SPairSet(const MonomialInfo *MI0, const gb_array &gb0,mtbb::task_arena& scheduler);
88#else
89 F4SPairSet(const MonomialInfo *MI0, const gb_array &gb0);
90#endif
91
93
94 void insert_generator(int deg, packed_monomial lcm, int column);
95 // The lcm is a pointer to the space in the polynomial itself
96
97 void insert_spair(pre_spair *p, int me);
98
99 void delete_spair(spair *p);
100
101 int find_new_pairs(bool remove_disjoints);
102 // returns the number of new pairs found, using the last element on this list
103
104 std::pair<bool,int> setThisDegree();
105
106 // int prepare_next_degree(int max, int &result_number);
107 // Returns the (sugar) degree being done next, and collects all (or at
108 // most 'max', if max>0) spairs in this lowest degree.
109 // Returns the degree, sets result_number.
110 // These spairs are not sorted in any way. Should they be?
111
112 std::pair<bool,spair> get_next_pair();
113 // get the next pair in this degree (the one 'prepare_next_degree' set up')
114
115 // discard all of the spairs in the current set degree
117
118 void display_spair(spair *p);
119 // A debugging routine which displays an spair
120
121 void display();
122 // A debugging routine which displays the spairs in the set
123
124 long n_unneeded_pairs() const { return nsaved_unneeded; }
125 // Returns how many pairs were created, then later removed due to
126 // spair criteria.
127
128 size_t numberOfSPairs() const { return mSPairs.size(); }
129
131 double secondsToCreatePrePairs() const { return mPrePairsSeconds; }
132 private:
133 F4MemoryBlock<pre_spair> PS; // passed to constructor routine
134 F4MemoryBlock<varpower_word> VP; // used for constructing new pairs
135 MemoryBlock mSPairLCMs; // used for spair lcms
136
138
140 const gb_array &gb;
141
142 std::vector<spair> mSPairs;
144 std::priority_queue<size_t,std::vector<size_t>,SPairCompare> mSPairQueue;
145
147
148 // stats
152
153#if defined (WITH_TBB)
154 mtbb::task_arena& mScheduler;
155#endif
156
157};
158
159
160// Local Variables:
161// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
162// indent-tabs-mode: nil
163// End:
Bump-pointer arena allocator for transient inner-loop allocations.
int construct_pairs(bool remove_disjoints)
MemoryBlock mSPairLCMs
long mThisDegree
std::pair< bool, spair > get_next_pair()
std::pair< bool, int > setThisDegree()
int remove_unneeded_pairs()
Definition f4-spairs.cpp:90
void delete_spair(spair *p)
Definition f4-spairs.cpp:66
double secondsToCreatePrePairs() const
void insert_generator(int deg, packed_monomial lcm, int column)
Definition f4-spairs.cpp:67
std::vector< spair > mSPairs
int max_varpower_size
void display()
long nsaved_unneeded
double secondsToMinimizePairs() const
void discardSPairsInCurrentDegree()
SPairCompare mSPairCompare
const gb_array & gb
double mPrePairsSeconds
void display_spair(spair *p)
void insert_spair(pre_spair *p, int me)
Definition f4-spairs.cpp:42
const MonomialInfo * M
F4SPairSet(const MonomialInfo *MI0, const gb_array &gb0)
Definition f4-spairs.cpp:17
F4MemoryBlock< varpower_word > VP
bool pair_not_needed(spair *p, gbelem *m)
Definition f4-spairs.cpp:81
double mMinimizePairsSeconds
size_t numberOfSPairs() const
F4MemoryBlock< pre_spair > PS
std::priority_queue< size_t, std::vector< size_t >, SPairCompare > mSPairQueue
long n_unneeded_pairs() const
int find_new_pairs(bool remove_disjoints)
spair * make_spair(SPairType type, int deg, int i, int j)
pre_spair * create_pre_spair(int i)
Thin RAII wrapper around memtailor::Arena providing bump-pointer array allocation with optional mutex...
Per-ring monomial layout / encoding helper used by F4GB.
Definition moninfo.hpp:108
Comparator on indices into an spair table, ordering by sugar degree then by the larger of the two par...
Definition f4-types.hpp:338
std::vector< gbelem * > gb_array
Definition f4-types.hpp:145
SPairType
Definition f4-types.hpp:89
Shared type vocabulary used across the F4 engine.
int p
F4MemoryBlock<T, NSLAB> — F4's templated slab bump allocator.
monomial_word * packed_monomial
Definition moninfo.hpp:78
MonomialInfo — F4's packed_monomial encoding plus operations.
F4's (variable, exponent) sparse-monomial ExponentList specialisation (legacy).