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

◆ minimalBettiNumbers()

BettiDisplay SchreyerFrame::minimalBettiNumbers ( bool stop_after_degree,
int top_slanted_degree,
int length_limit )

hi: . . . . . .

Definition at line 141 of file res-schreyer-frame.cpp.

144{
145 // The lo degree will be: mLoSlantedDegree.
146 // The highest slanted degree will either be mHiSlantedDegree, or
147 // top_slanted_degree (minimum of these two).
148 // The length we need to compute to is either maxLevel(), or length_limit+1.
149 // We set maxlevel to length_limit. We insist that length_limit <= maxLevel()
150 // - 2.
151 // Here is what needs to be computed:
152 // lo: . . . . . . .
153 // . . . . . . .
155 // Each dot in all rows other than 'hi' needs to have syzygies computed for
156 // it.
157 // if hi == mHiSlantedDegree, then we do NOT need to compute syzygies in this
158 // last row.
159 // else we need to compute syzygies in these rows, EXCEPT not at level
160 // maxlevel+1
161
162 computeFrame();
163
164 int top_degree; // slanted degree
165 if (stop_after_degree)
166 {
167 top_degree = std::min(top_slanted_degree, mHiSlantedDegree);
168 top_degree = std::max(mLoSlantedDegree, top_degree);
169 }
170 else
171 {
172 top_degree = mHiSlantedDegree;
173 }
174 // First: if length_limit is too low, extend the Frame
175 if (length_limit >= maxLevel())
176 {
177 std::cout << "WARNING: cannot extend resolution length" << std::endl;
178 length_limit = maxLevel() - 1;
179 // Extend the length of the Frame, change mMaxLength, possibly
180 // mHiSlantedDegree
181 // increase mComputationStatus if needed, mMinimalBetti, ...
182 // computeFrame()
183 }
184 // std::cout << "std::min(mMaxLength-1, length_limit): " << mMaxLength-1 << " " << length_limit << std::endl;
185 // length_limit = std::min(mMaxLength-1, length_limit);
186
187#if defined(WITH_TBB)
188 // build the dependency graph
190 {
191 //std::cout << "In dep graph" << std::endl;
192 mScheduler.execute([&] {
193 makeDependencyGraph(mDepGraph,length_limit+1,top_degree - mLoSlantedDegree+1,true);
194 mDepGraph.startComputation();
195 mDepGraph.waitForCompletion();
196 });
197 //std::cout << "Out dep graph" << std::endl;
198 }
199 // If this is not run, the 'computeRanks' calls below compute all of these elements
200#endif
201
202 // What needs to be computed?
203 // lodeg..hideg, level: 0..maxlevel. Note: need to compute at level
204 // maxlevel+1 in order to get min betti numbers at
205 // level maxlevel.
206 // Also note: if hideg is the highest degree that occurs in the frame, we do
207 // not need to compute any matrices for these.
208
209 // std::cout << "res-schreyer-frame:208, mLoSlantedDegree, top_degree, "
210 // "length_limit, mMaxLength: "
211 // << mLoSlantedDegree << " " << top_degree << " " << length_limit << " " << mMaxLength << std::endl;
212
213 for (int deg = mLoSlantedDegree; deg <= top_degree - 1; deg++)
214 for (int lev = 1; lev <= length_limit + 1; lev++)
215 {
216 computeRank(deg, lev);
217 }
218
219 for (int lev = 1; lev <= length_limit; lev++)
220 {
221 computeRank(top_degree, lev);
222 }
223
224 if (M2_gbTrace >= 1)
225 {
226 std::cout << "displaying stats" << std::endl;
228 monoid().show();
229 std::cout << "total setPoly: " << ResPolynomialConstructor::ncalls << std::endl;
230 std::cout << "total setPolyFromArray: "
232 std::cout << "total ~ResPolynomial: " << ResPolynomial::npoly_destructor << std::endl;
233
234 std::cout << "total time for make matrix: " << timeMakeMatrix
235 << std::endl;
236 std::cout << "total time for sort matrix: " << timeSortMatrix
237 << std::endl;
238 std::cout << "total time for reorder matrix: " << timeReorderMatrix
239 << std::endl;
240 std::cout << "total time for gauss matrix: " << timeGaussMatrix
241 << std::endl;
242 std::cout << "total time for clear matrix: " << timeClearMatrix
243 << std::endl;
244 std::cout << "total time for reset hash table: " << timeResetHashTable
245 << std::endl;
246 std::cout << "total time for computing ranks: " << timeComputeRanks
247 << std::endl;
248 std::cout << "total time for computing sparse ranks: " << timeComputeSparseRanks
249 << std::endl;
250 }
251
252 BettiDisplay B(mBettiMinimal); // copy
253 // std::cout << "in res-schreyer-frame.cpp, minimalBettiNumbers A\n";
254 // B.output();
255 B.resize(mLoSlantedDegree, top_degree, length_limit);
256 // std::cout << "in res-schreyer-frame.cpp, minimalBettiNumbers B\n";
257 // B.output();
258 // std::cout << "mMaxLength, mLevels.size(): " << mMaxLength << " " << mFrame.mLevels.size() << std::endl;
259 return B;
260}
static long npoly_destructor
void computeRank(int slanted_degree, int lev)
BettiDisplay mBettiMinimal
const ResMonoid & monoid() const
void showMemoryUsage() const
int M2_gbTrace
Definition m2-types.cpp:52
void makeDependencyGraph(int nlevels, int nslanted_degrees)

References computeFrame(), computeRank(), M2_gbTrace, makeDependencyGraph(), maxLevel(), mBettiMinimal, mHiSlantedDegree, mLoSlantedDegree, monoid(), mParallelizeByDegree, ResPolynomialConstructor::ncalls, ResPolynomialConstructor::ncalls_fromarray, ResPolynomial::npoly_destructor, BettiDisplay::resize(), ResMonoidDense::show(), showMemoryUsage(), timeClearMatrix, timeComputeRanks, timeComputeSparseRanks, timeGaussMatrix, timeMakeMatrix, timeReorderMatrix, timeResetHashTable, and timeSortMatrix.

Referenced by F4ResComputation::minimal_betti().