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

◆ start_computation()

void GB_comp::start_computation ( )
virtual

Implements GBComputation.

Definition at line 796 of file gb-homog2.cpp.

797{
799
800 for (;;)
801 {
802 if (is_done != COMP_COMPUTING) break;
803 is_done = computation_is_complete();
804 if (is_done != COMP_COMPUTING) break;
805 if (system_interrupted())
806 {
807 is_done = COMP_INTERRUPTED;
808 break;
809 }
810
811 switch (_state)
812 {
814 if (_spairs->n_elems() == 0 && _gens->n_elems() == 0)
815 {
817 is_done = COMP_DONE;
818 break;
819 }
821 if (stop_.stop_after_degree &&
822 _this_degree > stop_.degree_limit->array[0])
823 {
824 is_done = COMP_DONE_DEGREE_LIMIT;
825 break;
826 }
827
828 if (_use_hilb)
829 {
830 if (_hilb_new_elems)
831 {
832 // Recompute h, _hf_diff
833 RingElement *h = compute_hilbert_function();
834 if (h == nullptr)
835 {
836 is_done = COMP_INTERRUPTED;
837 break;
838 }
839 _hf_diff = (*h) - (*_hf_orig);
840 _hilb_new_elems = false;
841 }
843 if (error())
844 {
845 is_done = COMP_ERROR;
846 break;
847 }
849 }
850 if (M2_gbTrace >= 1)
851 {
852 buffer o;
853 o << '{' << _this_degree << '}';
854 o << '(';
855 if (_use_hilb) o << _hilb_n_in_degree << ',';
856 o << _spairs->n_elems() << ')';
857 emit_wrapped(o.str());
858 }
859
860 // Set state information for auto reduction, new pairs
861 _ar_i = _n_gb;
862 _ar_j = _ar_i + 1;
863 _np_i = _n_gb;
865 break;
866
867 case GB_COMP_S_PAIRS:
868 if (M2_gbTrace < 2)
869 {
871 }
872 else
873 switch (s_pair_step())
874 {
875 case SPAIR_MINGEN:
876 emit_wrapped("g");
877 break;
878 case SPAIR_GB:
879 emit_wrapped("m");
880 break;
881 case SPAIR_SYZ:
882 emit_wrapped("z");
883 break;
884 case SPAIR_ZERO:
885 emit_wrapped("o");
886 break;
887 case SPAIR_DONE:
889 break;
890 default:
891 emit_wrapped("ERROR");
892 break;
893 }
894 break;
895
896 case GB_COMP_GENS:
897 if (M2_gbTrace < 2)
898 {
900 }
901 else
902 switch (gen_step())
903 {
904 case SPAIR_MINGEN:
905 emit_wrapped("g");
906 break;
907 case SPAIR_SYZ:
908 emit_wrapped("z");
909 break;
910 case SPAIR_ZERO:
911 emit_wrapped("o");
912 break;
913 case SPAIR_DONE:
915 break;
916 default:
917 emit_wrapped("ERROR");
918 break;
919 }
920 break;
921
923 if (!auto_reduce_step())
924 {
926 if ((_strategy & STRATEGY_SORT) != 0)
927 {
928 gb_sort(
929 _np_i,
930 _n_gb - 1); // This is the range of elements to sort.
931 }
932 for (int j = _np_i; j < _n_gb; j++) _gb[j]->me = j;
933 }
934 break;
935
936 case GB_COMP_NEWPAIRS:
938 break;
939
940 case GB_COMP_DONE:
941 break;
942
944 is_done = COMP_NEED_RESIZE;
945 break;
946 }
947 }
948 if (M2_gbTrace >= 1) emit_line("");
949 if (M2_gbTrace >= 4)
950 {
951 buffer o;
952 o << "Number of gb elements = " << _n_gb << newline;
953 o << "Number of gcd=1 pairs = " << _n_saved_gcd << newline;
954 o << "Number of pairs computed = " << _n_pairs_computed << newline;
955 o << "Number of reductions = " << _n_reductions << newline;
956 emit(o.str());
957 }
958
959 // _GR->memstats();
960 set_status(is_done);
961}
enum ComputationStatusCode set_status(enum ComputationStatusCode)
Definition comp.cpp:66
StopConditions stop_
Definition comp.hpp:75
RingElement * compute_hilbert_function() const
int _n_pairs_computed
Definition gb-homog2.hpp:94
void gb_sort(int lo, int hi)
int _n_gb
Definition gb-homog2.hpp:92
int _state
Definition gb-homog2.hpp:78
bool _hilb_new_elems
int s_pair_step()
int _ar_i
Definition gb-homog2.hpp:79
int _ar_j
Definition gb-homog2.hpp:79
s_pair_heap * _gens
Definition gb-homog2.hpp:83
bool _use_hilb
int _this_degree
Definition gb-homog2.hpp:75
int gen_step()
s_pair_heap * _spairs
Definition gb-homog2.hpp:82
int next_degree()
RingElement * _hf_diff
ComputationStatusCode computation_is_complete() const
int _n_reductions
Definition gb-homog2.hpp:99
void flush_pairs(int deg)
bool auto_reduce_step()
int _hilb_n_in_degree
int _np_i
Definition gb-homog2.hpp:80
bool new_pairs_step()
int _strategy
int _n_saved_gcd
Definition gb-homog2.hpp:98
char * str()
Definition buffer.hpp:72
static int coeff_of(const RingElement *h, int deg)
Definition hilb.cpp:704
const int SPAIR_ZERO
Definition comp-gb.hpp:53
const int SPAIR_DONE
Definition comp-gb.hpp:50
const int SPAIR_GB
Definition comp-gb.hpp:51
const int SPAIR_SYZ
Definition comp-gb.hpp:52
const int SPAIR_MINGEN
Definition comp-gb.hpp:54
@ STRATEGY_SORT
ComputationStatusCode
Definition computation.h:53
@ COMP_NEED_RESIZE
Definition computation.h:55
@ 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
const int GB_COMP_DONE
Definition gb-homog2.hpp:56
const int GB_COMP_NEWPAIRS
Definition gb-homog2.hpp:55
const int GB_COMP_GENS
Definition gb-homog2.hpp:53
const int GB_COMP_AUTO_REDUCE
Definition gb-homog2.hpp:54
const int GB_COMP_NEED_RESIZE
Definition gb-homog2.hpp:51
const int GB_COMP_S_PAIRS
Definition gb-homog2.hpp:52
const int GB_COMP_NEWDEGREE
Definition gb-homog2.hpp:50
bool system_interrupted()
char newline[]
Definition m2-types.cpp:49
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
void emit(const char *s)
Definition text-io.cpp:41

References _ar_i, _ar_j, _gens, _hf_diff, _hilb_n_in_degree, _hilb_new_elems, _n_gb, _n_pairs_computed, _n_reductions, _n_saved_gcd, _np_i, _spairs, _state, _strategy, _this_degree, _use_hilb, auto_reduce_step(), hilb_comp::coeff_of(), COMP_COMPUTING, COMP_DONE, COMP_DONE_DEGREE_LIMIT, COMP_ERROR, COMP_INTERRUPTED, COMP_NEED_RESIZE, computation_is_complete(), compute_hilbert_function(), emit(), emit_line(), emit_wrapped(), error(), flush_pairs(), GB_COMP_AUTO_REDUCE, GB_COMP_DONE, GB_COMP_GENS, GB_COMP_NEED_RESIZE, GB_COMP_NEWDEGREE, GB_COMP_NEWPAIRS, GB_COMP_S_PAIRS, gb_sort(), gen_step(), M2_gbTrace, new_pairs_step(), newline, next_degree(), s_pair_step(), Computation::set_status(), SPAIR_DONE, SPAIR_GB, SPAIR_MINGEN, SPAIR_SYZ, SPAIR_ZERO, Computation::stop_, buffer::str(), STRATEGY_SORT, and system_interrupted().

Referenced by contains(), get_change(), get_gb(), get_initial(), get_mingens(), get_parallel_lead_terms(), get_syzygies(), matrix_lift(), and matrix_remainder().