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

◆ do_computation()

void gbA::do_computation ( )
private

Definition at line 2398 of file gb-default.cpp.

2399{
2401 spair *p;
2402
2403 // initial state is STATE_NEWDEGREE
2404
2405 if (stop_.always_stop) return; // don't change status
2406
2407 if ((ret = computation_is_complete()) != COMP_COMPUTING)
2408 {
2409 set_status(ret);
2410 return;
2411 }
2412
2413 if (M2_gbTrace == 15)
2414 {
2415 emit_line("[gb]");
2416 }
2417 else if (M2_gbTrace >= 1)
2418 {
2419 emit_wrapped("[gb]");
2420 }
2421 for (;;)
2422 {
2423 if (stop_.stop_after_degree && this_degree > stop_.degree_limit->array[0])
2424 {
2425 // Break out now if we don't have anything else to compute in this
2426 // degree.
2428 return;
2429 }
2431 {
2432 }
2433
2434 switch (state)
2435 {
2436 case STATE_NEWPAIRS:
2437 // Loop through all of the new GB elements, and
2438 // compute spairs. Start at np_i
2439 // np_i is initialized at the beginning, and also here.
2440 while (np_i < n_gb)
2441 {
2442 if (system_interrupted())
2443 {
2445 return;
2446 }
2447 if (gb[np_i])
2448 {
2449 if (gb[np_i]->minlevel & ELEM_MINGB) update_pairs(np_i);
2450 }
2451 np_i++;
2452 }
2453 state = STATE_HILB;
2454 [[fallthrough]];
2455
2456 case STATE_HILB:
2457 // If we are using hilbert function tracking:
2458 // Recompute the Hilbert function if new GB elements have been added
2459
2460 if (hilb_new_elems)
2461 {
2462 // Recompute h, hf_diff
2464 RingElement *h = hilb_comp::hilbertNumerator(hf);
2465 if (h == nullptr)
2466 {
2468 return;
2469 }
2470 hf_diff = (*h) - (*hf_orig);
2471 hilb_new_elems = false;
2472 }
2474 [[fallthrough]];
2475
2476 case STATE_NEWDEGREE:
2477 // Get the spairs and generators for the next degree
2478
2479 if (S->n_in_degree == 0)
2480 {
2481 // int old_degree = this_degree;
2483 this_degree); // sets this_degree
2484 // if (old_degree < this_degree)
2485 // first_in_degree = INTSIZE(gb);
2487 if (npairs == 0)
2488 {
2489 state = STATE_DONE;
2491 return;
2492 }
2493 if (stop_.stop_after_degree &&
2494 this_degree > stop_.degree_limit->array[0])
2495 {
2497 return;
2498 }
2499 if (use_hilb)
2500 {
2503 if (error())
2504 {
2505 // The previous line can give an error, which means that
2506 // the Hilbert
2507 // function declared was actually incorrect.
2509 return;
2510 }
2511 if (hilb_n_in_degree == 0) flush_pairs();
2512 }
2513 }
2514 if (M2_gbTrace == 15)
2515 {
2516 buffer o;
2517 o << "DEGREE " << this_degree;
2518 o << ", number of spairs = " << npairs;
2519 if (use_hilb)
2520 o << ", expected number in this degree = "
2522 emit_line(o.str());
2523 }
2524 else if (M2_gbTrace >= 1)
2525 {
2526 buffer o;
2527 o << '{' << this_degree << '}';
2528 o << '(';
2529 if (use_hilb) o << hilb_n_in_degree << ',';
2530 o << npairs << ')';
2531 emit_wrapped(o.str());
2532 }
2533 ar_i = n_gb;
2534 ar_j = ar_i + 1;
2536
2537 case STATE_SPAIRS:
2538 case STATE_GENS:
2539 // Compute the spairs for this degree
2540 while ((p = spair_set_next()) != nullptr)
2541 {
2543 npairs--;
2545
2546 if ((ret = computation_is_complete()) != COMP_COMPUTING)
2547 {
2548 set_status(ret);
2549 return;
2550 }
2551
2552 if (system_interrupted())
2553 {
2555 return;
2556 }
2557 }
2559 [[fallthrough]];
2560 // or state = STATE_NEWPAIRS
2561
2562 case STATE_AUTOREDUCE:
2563 // This is still possibly best performed when inserting a new
2564 // element
2565 // Perform the necessary or desired auto-reductions
2566 if (!is_local_gb)
2567 while (ar_i < n_gb)
2568 {
2569 if (gb[ar_i])
2570 while (ar_j < n_gb)
2571 {
2572 if (system_interrupted())
2573 {
2575 return;
2576 }
2577 if (gb[ar_j])
2578 {
2579 if (over_ZZ())
2580 {
2581 R->gbvector_auto_reduce_ZZ(_F,
2582 _Fsyz,
2583 gb[ar_i]->g.f,
2584 gb[ar_i]->g.fsyz,
2585 gb[ar_j]->g.f,
2586 gb[ar_j]->g.fsyz);
2587 }
2588 else
2589 {
2590 R->gbvector_auto_reduce(_F,
2591 _Fsyz,
2592 gb[ar_i]->g.f,
2593 gb[ar_i]->g.fsyz,
2594 gb[ar_j]->g.f,
2595 gb[ar_j]->g.fsyz);
2596 }
2597 }
2598 ar_j++;
2599 }
2600 ar_i++;
2601 ar_j = ar_i + 1;
2602 }
2604 break;
2605
2606 case STATE_DONE:
2607 return;
2608 }
2609 }
2610}
enum ComputationStatusCode set_status(enum ComputationStatusCode)
Definition comp.cpp:66
StopConditions stop_
Definition comp.hpp:75
char * str()
Definition buffer.hpp:72
enum ComputationStatusCode computation_is_complete()
int n_pairs_computed
GBRing * R
void flush_pairs()
int ar_j
enum gbA::gbA_state state
bool use_hilb
@ STATE_DONE
@ STATE_NEWDEGREE
@ STATE_NEWPAIRS
@ STATE_HILB
@ STATE_SPAIRS
@ STATE_GENS
@ STATE_AUTOREDUCE
int n_gb
int complete_thru_this_degree
int np_i
int hilb_n_in_degree
int ar_i
const FreeModule * _F
const FreeModule * _Fsyz
bool hilb_new_elems
bool over_ZZ() const
int npairs
RingElement * hf_diff
int this_degree
int spair_set_prepare_next_degree(int &nextdegree)
SPairSet * S
bool is_local_gb
bool process_spair(spair *p)
Matrix * make_lead_term_matrix()
spair * spair_set_next()
void update_pairs(int id)
static int coeff_of(const RingElement *h, int deg)
Definition hilb.cpp:704
static RingElement * hilbertNumerator(const Matrix *M)
Definition hilb.cpp:665
ComputationStatusCode
Definition computation.h:53
@ COMP_DONE
Definition computation.h:60
@ COMP_ERROR
Definition computation.h:56
@ COMP_DONE_DEGREE_LIMIT
Definition computation.h:61
@ COMP_COMPUTING
Definition computation.h:71
@ COMP_INTERRUPTED
Definition computation.h:57
int error()
Definition error.c:48
#define Matrix
Definition factory.cpp:14
void gb(IntermediateBasis &F, int n)
#define PrintingDegree
const int ELEM_MINGB
int p
bool system_interrupted()
int M2_gbTrace
Definition m2-types.cpp:52
void emit_wrapped(const char *s)
Definition text-io.cpp:27
void emit_line(const char *s)
Definition text-io.cpp:47

References _F, _Fsyz, ar_i, ar_j, hilb_comp::coeff_of(), COMP_COMPUTING, COMP_DONE, COMP_DONE_DEGREE_LIMIT, COMP_ERROR, COMP_INTERRUPTED, complete_thru_this_degree, computation_is_complete(), ELEM_MINGB, emit_line(), emit_wrapped(), error(), flush_pairs(), gb(), hf_diff, hilb_n_in_degree, hilb_new_elems, hilb_comp::hilbertNumerator(), is_local_gb, M2_gbTrace, make_lead_term_matrix(), Matrix, n_gb, n_pairs_computed, np_i, npairs, over_ZZ(), p, PrintingDegree, process_spair(), R, S, Computation::set_status(), spair_set_next(), spair_set_prepare_next_degree(), state, STATE_AUTOREDUCE, STATE_DONE, STATE_GENS, STATE_HILB, STATE_NEWDEGREE, STATE_NEWPAIRS, STATE_SPAIRS, Computation::stop_, buffer::str(), system_interrupted(), this_degree, update_pairs(), and use_hilb.

Referenced by start_computation().