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

◆ computeHomogeneous()

void NCGroebner::computeHomogeneous ( int softDegreeLimit)

Definition at line 69 of file NCGroebner.cpp.

70{
71 size_t n_spairs = 0;
72 while (!mOverlapTable.isFinished(softDegreeLimit))
73 {
74 auto degSet = mOverlapTable.nextDegreeOverlaps();
75 auto toBeProcessed = degSet.second;
76 if (M2_gbTrace >= 1)
77 {
78 buffer o;
79 o << "[" << degSet.first << "](" << toBeProcessed->size() << ")";
80 emit(o.str());
81 }
82 while(!toBeProcessed->empty())
83 {
84 auto overlap = toBeProcessed->front();
85 //if this is a `real' overlap, and the overlap is not necessary, then move
86 //on to the next overlap.
87 if (std::get<1>(overlap) != -1 && !isOverlapNecessary(overlap))
88 {
89 toBeProcessed->pop_front();
90 if (M2_gbTrace >= 3)
91 {
92 std::cout << "Reduction avoided using 2nd criterion." << std::endl;
93 std::cout << "table after pop:";
94 mOverlapTable.dump(std::cout,true);
95 }
96 // TODO: is this logic correct? Is the overlap actually skipped?
97 continue;
98 }
99 auto overlapPoly = createOverlapPoly(overlap);
100
101 n_spairs++;
102 auto redOverlapPoly = twoSidedReduction(overlapPoly);
103 delete overlapPoly;
104
105 if (!freeAlgebra().is_zero(*redOverlapPoly))
106 {
107 addToGroebnerBasis(redOverlapPoly);
109 updateOverlaps(redOverlapPoly);
110 }
111 else
112 {
113 // if reduction is zero
114 if (M2_gbTrace >= 4)
115 {
116 std::cout << "Overlap " << overlap << " reduced to zero."
117 << std::endl;
118 }
119 }
120 toBeProcessed->pop_front();
121 }
122 // remove the lowest degree overlaps from the overlap table
123 mOverlapTable.removeLowestDegree();
124 }
125 if (M2_gbTrace >= 1)
126 {
127 buffer o;
128 o << "[NCGB] number of spair reductions: " << n_spairs;
129 emit_line(o.str());
130 }
131}
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().