Macaulay2 Engine
Loading...
Searching...
No Matches
gb-homog2.hpp
Go to the documentation of this file.
1// Copyright 1996 Michael E. Stillman
2#ifndef _gb_hh_
3#define _gb_hh_
4
37
38#include "relem.hpp"
39#include "matrix.hpp"
40#include "polyring.hpp"
41
42#include "comp-gb.hpp"
43
44#include "spair.hpp"
45#include "gbweight.hpp"
46
47class hilb_comp;
48
49// These are the possible states of a GB computation
50const int GB_COMP_NEWDEGREE = 1;
51const int GB_COMP_NEED_RESIZE = 2;
52const int GB_COMP_S_PAIRS = 3;
53const int GB_COMP_GENS = 4;
54const int GB_COMP_AUTO_REDUCE = 5;
55const int GB_COMP_NEWPAIRS = 6;
56const int GB_COMP_DONE = 7;
57
63class GB_comp : public GBComputation
64{
65 private:
66 // Ring information
70 const Monoid *_M;
71 const Ring *_K;
72
73 const FreeModule *_F;
76
77 // state information
78 int _state; // GB_COMP_*
79 int _ar_i, _ar_j; // State info used for autoreduction
80 int _np_i; // State info used for new pairs
81
84
86 VECTOR(monideal_pair *) _monideals; // baggage for each is 'gb_elem *'
87
88 // Syzygies collected
90
91 // statistics information, much is kept with the s_set
92 int _n_gb;
96 int _n_syz; // Same as _syz.length()
97
100
101 // Syzygy type
105 int _strategy; // USE_SORT, STRATEGY_LONGPOLYNOMIALS, or both
106
107 // Hilbert function information
109 bool _hilb_new_elems; // True if any new elements since HF was last computed
110 int _hilb_n_in_degree; // The number of new elements that we expect to find
111 // in this degree.
113 const RingElement
114 *_hf_orig; // The Hilbert function that we are given at the beginning
116 *_hf_diff; // The difference between hf_orig and the computed hilb fcn
117 private:
118 void initialize0(const Matrix *m, int csyz, int nsyz, M2_arrayint gb_weights);
119 void initialize(const Matrix *m,
120 int csyz,
121 int nsyz,
122 M2_arrayint gb_weights,
123 int strategy);
124
126 const Matrix *gb,
127 const Matrix *mchange);
128
129 // S-pair control
130 s_pair *new_var_pair(gb_elem *p, const int *lcm);
131 s_pair *new_ring_pair(gb_elem *p, const int *lcm);
132 s_pair *new_s_pair(gb_elem *p, gb_elem *q, const int *lcm);
133 s_pair *new_gen(int i, gbvector *f, ring_elem denom);
134 void remove_pair(s_pair *&p);
135
136 void find_pairs(gb_elem *p);
137 void compute_s_pair(s_pair *p);
138 void gb_reduce(gbvector *&f, gbvector *&fsyz);
139 void gb_geo_reduce(gbvector *&f, gbvector *&fsyz);
140 void gb_insert(gbvector *f, gbvector *fsyz, int ismin);
141
142 int gb_sort_partition(int lo, int hi);
143 void gb_sort(int lo, int hi);
144
145 // Hilbert function use
146 void flush_pairs(int deg);
147 RingElement /* or null */ *compute_hilbert_function() const;
148
149 int next_degree();
151
152 bool new_pairs_step();
153 int s_pair_step();
154 int gen_step();
155 bool auto_reduce_step();
156
158 virtual ~GB_comp();
159
160 virtual void remove_gb() {}
161 // Adding generators
162 void add_gens(int lo, int hi, const Matrix *m);
163
164 void debug_out(s_pair *q) const;
165
166 virtual bool stop_conditions_ok() { return true; }
167 public:
169 // Computation routines //
171 static GB_comp *create(const Matrix *m,
172 M2_bool collect_syz,
173 int n_rows_to_keep,
174 M2_arrayint gb_weights,
175 int strategy,
176 M2_bool use_max_degree,
177 int max_degree);
178
179 static GB_comp *create_forced(const Matrix *m,
180 const Matrix *gb,
181 const Matrix *mchange);
182
183 virtual int kind() { return 1; }
184 void start_computation();
185
186 virtual const PolynomialRing *get_ring() const { return originalR; }
187 virtual Computation /* or null */ *set_hilbert_function(const RingElement *h);
188
189 virtual const Matrix /* or null */ *get_gb();
190
191 virtual const Matrix /* or null */ *get_mingens();
192
193 virtual const Matrix /* or null */ *get_change();
194
195 virtual const Matrix /* or null */ *get_syzygies();
196
197 virtual const Matrix /* or null */ *get_initial(int nparts);
198
199 virtual const Matrix /* or null */ *get_parallel_lead_terms(M2_arrayint w);
200
201 virtual const Matrix /* or null */ *matrix_remainder(const Matrix *m);
202
203 virtual M2_bool matrix_lift(const Matrix *m,
204 const Matrix /* or null */ **result_remainder,
205 const Matrix /* or null */ **result_quotient);
206
207 virtual int contains(const Matrix *m);
208
209 virtual void text_out(buffer &o) const;
210 /* This displays statistical information, and depends on the
211 M2_gbTrace value */
212
213 virtual int complete_thru_degree() const;
214 // The computation is complete up through this degree.
215};
216#endif
217
218// Local Variables:
219// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
220// indent-tabs-mode: nil
221// End:
Abstract base for long-running, resumable engine computations (GBComputation, ResolutionComputation,...
Definition comp.hpp:70
Engine-side free module R^n over a Ring.
Definition freemod.hpp:66
virtual const Matrix * get_change()
RingElement * compute_hilbert_function() const
int _n_pairs_computed
Definition gb-homog2.hpp:94
void gb_geo_reduce(gbvector *&f, gbvector *&fsyz)
void gb_sort(int lo, int hi)
int _n_gb
Definition gb-homog2.hpp:92
void gb_reduce(gbvector *&f, gbvector *&fsyz)
int _n_syz
Definition gb-homog2.hpp:96
int _state
Definition gb-homog2.hpp:78
const Ring * _K
Definition gb-homog2.hpp:71
void start_computation()
const FreeModule * _Fsyz
Definition gb-homog2.hpp:74
VECTOR(gbvector *) _syz
s_pair * new_ring_pair(gb_elem *p, const int *lcm)
bool _hilb_new_elems
virtual const Matrix * get_gb()
virtual M2_bool matrix_lift(const Matrix *m, const Matrix **result_remainder, const Matrix **result_quotient)
int _n_subring
Definition gb-homog2.hpp:95
void remove_pair(s_pair *&p)
int s_pair_step()
const Monoid * _M
Definition gb-homog2.hpp:70
virtual const PolynomialRing * get_ring() const
bool _collect_syz
void find_pairs(gb_elem *p)
static GB_comp * create(const Matrix *m, M2_bool collect_syz, int n_rows_to_keep, M2_arrayint gb_weights, int strategy, M2_bool use_max_degree, int max_degree)
virtual const Matrix * get_initial(int nparts)
int _ar_i
Definition gb-homog2.hpp:79
void initialize0(const Matrix *m, int csyz, int nsyz, M2_arrayint gb_weights)
Definition gb-homog2.cpp:28
VECTOR(monideal_pair *) _monideals
virtual bool stop_conditions_ok()
virtual const Matrix * get_mingens()
int _ar_j
Definition gb-homog2.hpp:79
const FreeModule * _F
Definition gb-homog2.hpp:73
void gb_insert(gbvector *f, gbvector *fsyz, int ismin)
virtual void remove_gb()
virtual void text_out(buffer &o) const
virtual int complete_thru_degree() const
s_pair * new_var_pair(gb_elem *p, const int *lcm)
virtual int contains(const Matrix *m)
s_pair_heap * _gens
Definition gb-homog2.hpp:83
int gb_sort_partition(int lo, int hi)
int _n_gens_left
Definition gb-homog2.hpp:93
bool _use_hilb
const GBWeight * weightInfo_
Definition gb-homog2.hpp:69
int _this_degree
Definition gb-homog2.hpp:75
s_pair * new_s_pair(gb_elem *p, gb_elem *q, const int *lcm)
void compute_s_pair(s_pair *p)
int _n_rows_per_syz
int gen_step()
s_pair_heap * _spairs
Definition gb-homog2.hpp:82
GBRing * _GR
Definition gb-homog2.hpp:68
const PolynomialRing * originalR
Definition gb-homog2.hpp:67
void initialize(const Matrix *m, int csyz, int nsyz, M2_arrayint gb_weights, int strategy)
Definition gb-homog2.cpp:84
int next_degree()
RingElement * _hf_diff
virtual const Matrix * get_syzygies()
virtual const Matrix * matrix_remainder(const Matrix *m)
virtual Computation * set_hilbert_function(const RingElement *h)
ComputationStatusCode computation_is_complete() const
int _n_reductions
Definition gb-homog2.hpp:99
virtual const Matrix * get_parallel_lead_terms(M2_arrayint w)
VECTOR(gb_elem *) _gb
s_pair * new_gen(int i, gbvector *f, ring_elem denom)
void initialize_forced(const Matrix *m, const Matrix *gb, const Matrix *mchange)
static GB_comp * create_forced(const Matrix *m, const Matrix *gb, const Matrix *mchange)
void flush_pairs(int deg)
virtual int kind()
int _n_saved_hilb
bool _is_ideal
bool auto_reduce_step()
int _hilb_n_in_degree
const RingElement * _hf_orig
void add_gens(int lo, int hi, const Matrix *m)
int _np_i
Definition gb-homog2.hpp:80
bool new_pairs_step()
void debug_out(s_pair *q) const
virtual ~GB_comp()
int _strategy
int _n_saved_gcd
Definition gb-homog2.hpp:98
A Groebner basis computation class for homogeneous input modules.
Definition gb-homog2.hpp:64
Polynomial-ring view tuned for the inner loop of classical Buchberger Groebner-basis computations.
Definition gbring.hpp:120
Heuristic-weight evaluator for gbvectors, used during Groebner basis computation to drive the S-pair ...
Definition gbweight.hpp:67
Engine-side commutative monomial monoid: variable names, ordering, multidegree machinery,...
Definition monoid.hpp:89
Abstract base for the engine's polynomial-ring hierarchy.
Definition polyring.hpp:96
Front-end-visible "ring element" value: an engine ring_elem paired with the Ring* that gives it meani...
Definition relem.hpp:67
xxx xxx xxx
Definition ring.hpp:102
Computation of Hilbert functions.
Definition hilb.hpp:93
GBComputation — abstract base of every Groebner-basis algorithm in the engine.
ComputationStatusCode
Definition computation.h:53
#define Matrix
Definition factory.cpp:14
void gb(IntermediateBasis &F, int n)
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
GBWeight — packed-weight evaluator that drives S-pair selection.
int p
char M2_bool
Definition m2-types.h:82
Matrix — the engine's immutable homomorphism F -> G between free modules.
PolynomialRing — abstract polynomial-ring base, the engine's most-reused class.
RingElement — tagged (Ring*, ring_elem) pair, the engine's universal element type.
gb_elem / s_pair / s_pair_heap — basis-element record, S-pair work unit, and S-pair priority queue fo...