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

◆ computeInhomogeneous()

void NCGroebner::computeInhomogeneous ( int softDegreeLimit)

Definition at line 133 of file NCGroebner.cpp.

134{
135 size_t n_spairs = 0;
136 while (!mOverlapTable.isFinished(softDegreeLimit))
137 {
138 auto degSet = mOverlapTable.nextDegreeOverlaps();
139 auto toBeProcessed = degSet.second;
140 if (M2_gbTrace >= 1)
141 {
142 buffer o;
143 o << "[" << degSet.first << "](" << toBeProcessed->size() << ")";
144 emit(o.str());
145 }
146 while(!toBeProcessed->empty())
147 {
148 auto overlap = toBeProcessed->front();
149 //if this is a `real' overlap, and the overlap is not necessary, then move
150 //on to the next overlap.
151 if (std::get<1>(overlap) != -1 && !isOverlapNecessary(overlap))
152 {
153 toBeProcessed->pop_front();
154 if (M2_gbTrace >= 2)
155 {
156 std::cout << "Reduction avoided using 2nd criterion." << std::endl;
157 std::cout << "table after pop:";
158 mOverlapTable.dump(std::cout,true);
159 }
160 // TODO: is this logic correct? Is the overlap actually skipped?
161 continue;
162 }
163 auto overlapPoly = createOverlapPoly(overlap);
164
165 n_spairs++;
166 auto redOverlapPoly = twoSidedReduction(overlapPoly);
167 delete overlapPoly;
168
169 if (!freeAlgebra().is_zero(*redOverlapPoly))
170 {
171 addToGroebnerBasis(redOverlapPoly);
173 updateOverlaps(redOverlapPoly);
174 }
175 else
176 {
177 // if reduction is zero
178 if (M2_gbTrace >= 4)
179 {
180 std::cout << "Overlap " << overlap << " reduced to zero."
181 << std::endl;
182 }
183 }
184 toBeProcessed->pop_front();
185 }
186 // remove the lowest degree overlaps from the overlap table
187 mOverlapTable.removeLowestDegree();
188 }
189 if (M2_gbTrace >= 1)
190 {
191 buffer o;
192 o << "[NCGB] number of spair reductions: " << n_spairs;
193 emit_line(o.str());
194 }
195}
auto twoSidedReduction(const ConstPolyList &reducees) const -> ConstPolyList
void updateOverlaps(const Poly *toAdd)
void autoreduceByLastElement()
auto isOverlapNecessary(Overlap o) const -> bool
OverlapTable mOverlapTable
static auto createOverlapPoly(const FreeAlgebra &A, const PolyList &polyList, int polyIndex1, int polyIndex2, int overlapIndex) -> Poly *
const FreeAlgebra & freeAlgebra() const
void addToGroebnerBasis(Poly *toAdd)
int size()
Definition buffer.hpp:70
char * str()
Definition buffer.hpp:72
int M2_gbTrace
Definition m2-types.cpp:52
void emit_line(const char *s)
Definition text-io.cpp:47
void emit(const char *s)
Definition text-io.cpp:41

References addToGroebnerBasis(), autoreduceByLastElement(), createOverlapPoly(), emit(), emit_line(), freeAlgebra(), isOverlapNecessary(), M2_gbTrace, mOverlapTable, buffer::size(), buffer::str(), twoSidedReduction(), and updateOverlaps().

Referenced by compute().