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

◆ calc_gb()

enum ComputationStatusCode gb2_comp::calc_gb ( int deg)
virtual

Implements gb_node.

Definition at line 684 of file res-a2-gb.cpp.

685{
687 if (this_degree > deg) return COMP_DONE;
688 if (state == STATE_DONE) return COMP_DONE; // This includes knowledge
689 // that there will be no new generators.
690 if (this_degree < deg)
691 {
692 // Now make sure that previous computations have been done:
693 ret = calc_gens(deg - 1);
694 if (ret != COMP_DONE) return ret;
695 }
696 // At this point, we have completely computed a GB with new gens
697 // in this degree. Depending on whether we stopped
698 // prematurely, our state will be one of STATE_NEW_DEGREE,
699 // STATE_GB, STATE_GENS.
700
701 buffer o1;
702
703 if (state == STATE_NEW_DEGREE)
704 {
705 if (use_hilb)
706 {
707 RingElement *hsyz;
708 const PolynomialRing *DR = originalR->get_degree_ring();
709 RingElement *h = RingElement::make_raw(DR, DR->zero());
710 if (syz != nullptr)
711 {
712 hsyz = syz->hilbertNumerator();
713 if (hsyz == nullptr) return COMP_INTERRUPTED;
714 // o1 << "hsyz = "; hsyz->text_out(o);
715 h = (*h) + (*hsyz);
716 }
717 RingElement *hf1 = hilbertNumerator();
718 if (hf1 == nullptr) return COMP_INTERRUPTED;
719 h = (*h) + (*hf1);
720 RingElement *hF = hilb_comp::hilbertNumerator(F);
721 if (hF == nullptr) return COMP_INTERRUPTED;
722 h = (*h) - (*hF);
723
724#if 0
725// o1 << "\nhf = "; hf1->text_out(o1);
726// o1 << "\nhF = "; hF->text_out(o1);
727// o1 << "\nh = "; h->text_out(o1);
728// o1 << "\n";
729// emit(o1.str());
730// o1.reset();
731#endif
732 if (M2_gbTrace >= 1 && n_gb_syz != 0)
733 {
734 buffer o;
735 o << "<WARNING: remaining nsyz+ngb = " << n_gb_syz << ">";
736 emit(o.str());
737 }
738
740 if (error()) return COMP_ERROR;
741 }
742
743 // Compute new s-pairs
744 for (int i = n_gb_first; i < n_gb; i++) find_pairs(gb[i]);
745
746 state = STATE_GB;
748 int npairs = get_pairs();
749 if (M2_gbTrace >= 1 && npairs > 0)
750 {
751 buffer o;
752 // Should only display this if there are some pairs.
753 o << '[' << level << ',' << npairs;
754 if (use_hilb) o << ",e" << n_gb_syz; // << "," << n1 << "," << n2;
755 o << ']';
756 emit(o.str());
757 }
758 }
759
760 if (state == STATE_GB)
761 {
762 ret = COMP_COMPUTING;
763 // Now compute all the s-pairs here.
764 for (;;)
765 {
766 if (ret != COMP_COMPUTING) break;
767 if (system_interrupted())
768 {
769 ret = COMP_INTERRUPTED;
770 break;
771 }
772 // Check ending conditions...
773 if (!s_pair_step())
774 {
775 ret = COMP_DONE;
777 }
778 }
779 }
780
781 if (state == STATE_GENS && orig_syz > 0)
782 {
783 // Get the generators of the same degree, since these
784 // may produce syzygies of this degree.
785 ret = gens->calc_gb(deg);
786 if (ret == COMP_DONE)
787 {
788 // Cleanup, go to next degree.
789 end_degree();
790 }
791 }
792 // MES: put out an endl if M2_gbTrace >= 1?
793
794 // Is this where we should compute the HF again: for use by the
795 // previous node... Do we really have to compute it twice per degree/level
796 // node?
797
798 return ret;
799}
ring_elem zero() const
Definition ring.hpp:359
static RingElement * make_raw(const Ring *R, ring_elem f)
Definition relem.cpp:20
char * str()
Definition buffer.hpp:72
int n_gb_first
Definition res-a2.hpp:126
gb_node * syz
Definition res-a2.hpp:137
enum ComputationStatusCode calc_gens(int deg)
int level
Definition res-a2.hpp:123
int orig_syz
Definition res-a2.hpp:157
int get_pairs()
int n_gb
Definition res-a2.hpp:141
int this_degree
Definition res-a2.hpp:125
void find_pairs(gb_elem *p)
int state
Definition res-a2.hpp:124
void end_degree()
FreeModule * F
Definition res-a2.hpp:120
char use_hilb
Definition res-a2.hpp:164
const PolynomialRing * originalR
Definition res-a2.hpp:113
bool s_pair_step()
virtual RingElement * hilbertNumerator()
gb_node * gens
Definition res-a2.hpp:138
int n_gb_syz
Definition res-a2.hpp:169
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_COMPUTING
Definition computation.h:71
@ COMP_INTERRUPTED
Definition computation.h:57
int error()
Definition error.c:48
void gb(IntermediateBasis &F, int n)
bool system_interrupted()
int M2_gbTrace
Definition m2-types.cpp:52
#define STATE_GENS
Definition res-a2.hpp:16
#define STATE_DONE
Definition res-a2.hpp:12
#define STATE_NEW_DEGREE
Definition res-a2.hpp:13
#define STATE_GB
Definition res-a2.hpp:15
void emit(const char *s)
Definition text-io.cpp:41

References calc_gens(), hilb_comp::coeff_of(), COMP_COMPUTING, COMP_DONE, COMP_ERROR, COMP_INTERRUPTED, emit(), end_degree(), error(), F, find_pairs(), gb(), gens, get_pairs(), hilbertNumerator(), hilb_comp::hilbertNumerator(), level, M2_gbTrace, RingElement::make_raw(), n_gb, n_gb_first, n_gb_syz, orig_syz, originalR, s_pair_step(), state, STATE_DONE, STATE_GB, STATE_GENS, STATE_NEW_DEGREE, buffer::str(), system_interrupted(), syz, this_degree, use_hilb, and Ring::zero().

Referenced by calc_gens().