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

◆ start_computation()

void res2_comp::start_computation ( )
virtual

Implements ResolutionComputation.

Definition at line 266 of file res-a0.cpp.

267{
268 int n, level;
269 res2_pair *p;
270
271 if (status() == COMP_DONE) return;
273
274 if (stop_.length_limit->len > 0)
275 {
277 // this also sets length_limit
278 increase_level(stop_.length_limit->array[0]);
279 else
280 length_limit = stop_.length_limit->array[0];
281 }
282 int compute_level = COMPUTE_RES;
283
284 for (level = 1; level <= length_limit + 1; level++) DO(skeleton(level));
285
286 if (M2_gbTrace >= 3)
287 {
288 buffer o;
289 o << "--- The total number of pairs in each level/slanted degree -----"
290 << newline;
291 M2_arrayint a = betti_skeleton();
292 betti_display(o, a);
293 emit(o.str());
294 }
295
296 // The skeleton routine sets the following:
297 // hidegree: highest slanted degree found so far
298 // a flag for each level as to whether the level has new elements
299 // since the last time the pairs were sorted for reduction
300
301 if (compute_level <= COMPUTE_SKELETON)
302 {
304 return;
305 }
306
307 // Set the monomial order for each level, and then prepare for
308 // reductions
309 for (level = 1; level <= length_limit + 1; level++)
310 {
311 if (resn[level]->state != RES_MONORDER) continue;
312 // The sort will use compare_num's from syz->comp->compare_num
313 // and will use these numbers to break ties:
314 for (n = 0, p = resn[level]->pairs; p != nullptr; p = p->next, n++)
315 p->compare_num = n;
316 sort_monorder(resn[level]->pairs);
317 for (n = 0, p = resn[level]->pairs; p != nullptr; p = p->next, n++)
318 p->compare_num = n;
319 sort_reduction(resn[level]->pairs);
320 resn[level]->state = RES_REDUCTIONS;
321 resn[level]->next_pair = resn[level]->pairs;
322 }
323
324 for (level = 1; level <= length_limit + 1; level++)
325 {
326 resn[level]->next_pair = resn[level]->pairs;
327 }
328
329 // Here: possibly compute the resolution of the monomial ideal first.
330
331 if (compute_level <= COMPUTE_MONOMIAL_RES)
332 {
334 return;
335 }
336
337 if (do_by_level != 0)
338 {
339 for (level = 1; level <= length_limit; level++)
340 DO(do_pairs_by_level(level));
342 return;
343 }
344
345 if (do_by_degree)
346 {
347 for (int deg = 0; deg <= hidegree; deg++)
348 {
349 if (stop_.stop_after_degree &&
350 stop_.degree_limit->array[0] - lodegree < deg)
351 // if (DegreeLimit != NULL && deg > *DegreeLimit - lodegree)
352 {
354 return;
355 }
356 if (M2_gbTrace >= 1)
357 {
358 buffer o;
359 o << '{' << deg + lodegree << '}';
360 emit(o.str());
361 }
362 for (level = 1; level <= length_limit; level++)
363 DO(do_pairs_by_degree(level, deg));
364 }
366 return;
367 }
368
369 // Now do all of the reductions
370 for (int deg = 0; deg <= hidegree; deg++)
371 {
372 if (stop_.stop_after_degree &&
373 stop_.degree_limit->array[0] - lodegree < deg)
374 // if (DegreeLimit != NULL && deg > *DegreeLimit - lodegree)
375 {
377 return;
378 }
379 if (M2_gbTrace >= 1)
380 {
381 buffer o;
382 o << '{' << deg + lodegree << '}';
383 emit(o.str());
384 }
385 for (level = 1; level <= length_limit + 1; level++)
386 {
387 DO(do_all_pairs(level, deg));
388 if (level > projdim) break;
389 }
390 }
391#if 0
392// //This is the older, working version...
393// // Now do all of the reductions
394// for (int deg=0; deg<=hidegree; deg++)
395// {
396// if (DegreeLimit != NULL && deg > *DegreeLimit - lodegree)
397// {
398// set_status(COMP_DONE_DEGREE_LIMIT);
399// return;
400// }
401// if (M2_gbTrace >= 1)
402// {
403// buffer o;
404// o << '{' << deg+lodegree << '}';
405// emit(o.str());
406// }
407// for (level=1; level<=length_limit+1; level++)
408// {
409// DO(do_pairs(level,deg));
410// }
411// }
412#endif
414}
enum ComputationStatusCode status() const
Definition comp.hpp:100
enum ComputationStatusCode set_status(enum ComputationStatusCode)
Definition comp.cpp:66
StopConditions stop_
Definition comp.hpp:75
static void betti_display(buffer &o, M2_arrayint a)
Definition comp-res.cpp:207
char * str()
Definition buffer.hpp:72
unsigned char do_by_degree
Definition res-a0.hpp:175
int hidegree
Definition res-a0.hpp:138
int projdim
Definition res-a0.hpp:155
enum ComputationStatusCode do_pairs_by_degree(int level, int degree)
Definition res-a0.cpp:214
enum ComputationStatusCode do_pairs_by_level(int level)
Definition res-a0.cpp:151
int length_limit
Definition res-a0.hpp:147
void increase_level(int newmax)
Definition res-a0.cpp:75
void sort_reduction(res2_pair *&p)
Definition res-a0.cpp:931
M2_arrayint betti_skeleton() const
Definition res-a0.cpp:1816
int lodegree
Definition res-a0.hpp:137
enum ComputationStatusCode skeleton(int level)
Definition res-a0.cpp:40
unsigned char do_by_level
Definition res-a0.hpp:173
enum ComputationStatusCode do_all_pairs(int level, int degree)
Definition res-a0.cpp:92
void sort_monorder(res2_pair *&p)
Definition res-a0.cpp:924
@ COMP_DONE
Definition computation.h:60
@ COMP_DONE_DEGREE_LIMIT
Definition computation.h:61
@ COMP_COMPUTING
Definition computation.h:71
int p
char newline[]
Definition m2-types.cpp:49
int M2_gbTrace
Definition m2-types.cpp:52
static gmp_randstate_t state
Definition random.cpp:18
#define DO(CALL)
Definition res-a0.cpp:256
const int COMPUTE_RES
Definition res-a0.hpp:87
@ RES_REDUCTIONS
Definition res-a0.hpp:55
@ RES_MONORDER
Definition res-a0.hpp:51
const int COMPUTE_MONOMIAL_RES
Definition res-a0.hpp:86
const int COMPUTE_SKELETON
Definition res-a0.hpp:84
void emit(const char *s)
Definition text-io.cpp:41

References ResolutionComputation::betti_display(), betti_skeleton(), COMP_COMPUTING, COMP_DONE, COMP_DONE_DEGREE_LIMIT, COMPUTE_MONOMIAL_RES, COMPUTE_RES, COMPUTE_SKELETON, DO, do_all_pairs(), do_by_degree, do_by_level, do_pairs_by_degree(), do_pairs_by_level(), emit(), hidegree, increase_level(), length_limit, lodegree, M2_gbTrace, newline, p, projdim, RES_MONORDER, RES_REDUCTIONS, Computation::set_status(), skeleton(), sort_monorder(), sort_reduction(), state, Computation::status(), Computation::stop_, and buffer::str().