Macaulay2 Engine
Loading...
Searching...
No Matches
gb-walk.cpp
Go to the documentation of this file.
1/* Copyright 2007, Michael E. Stillman */
2
3#include "gb-walk.hpp"
4
5#include <assert.h>
6
8#include "error.h"
9#include "gbring.hpp"
12#include "reducedgb-marked.hpp"
13
14class Computation;
15class Matrix;
16class buffer;
17class RingElement;
18
36{
37 int nvars;
38 long **order;
39
40 public:
43
44 const long *part(int i) const
45 {
46 assert(i < nvars);
47 return order[i];
48 }
49 int compare(long *m1, long *m2) const;
50
51 int minpart(long *m) const;
52 // returns the smallest integer i such that part(j) . m = 0 for j < i
53
54 long value(int i, long *monom) const;
55 // return part(i) . monom
56
58
59 // Routines needed:
60 int facet_compare(long *mon1, long *mon2); // TODO
61};
62
64
65GBWalker::GBWalker(MarkedGB *G0, long **order1, long **order2)
66 : R(G0->get_gb_ring()),
67 F(G0->get_ambient_FreeModule()),
68 G(G0),
69 monorder1(order1), // or create this from the monomial order?
70 monorder2(order2),
71 ww(nullptr)
72{
73 // TODO: need to set what else?
74 //
75}
76
77GBWalker::GBWalker(const Matrix *gb_under_order1,
78 const MonomialOrdering *order1)
79{
80 (void) gb_under_order1;
81 (void) order1;
82}
83
84GBWalker *GBWalker::create(const Matrix *gb_under_order1,
85 const MonomialOrdering *order1)
86{
87 // TODO MES: TO WRITE
88 return new GBWalker(gb_under_order1, order1);
89}
90
92{
93 // TODO MES: TO WRITE
94}
95
97{
98 // TODO MES: TO WRITE
99 return true;
100}
101
103// return the GB of g, keep = 0 or 1.
104{
105 M2_arrayint weights = M2_makearrayint(R->n_vars());
106 for (int i = 0; i < R->n_vars(); i++) weights->array[i] = 1;
107
109 false, // collect syz
110 -1,
111 weights,
112 false,
113 -1,
114 0,
115 0,
116 0 // TBB numThreads
117 /* , max_reduction_count */
118 );
119 G0->set_stop_conditions(false,
120 nullptr,
121 -1,
122 -1, // syzygy limit
123 -1,
124 -1,
125 -1,
126 false,
127 nullptr);
128 return G0;
129}
130
132{
133 // Initialize the local variables of the computation
135 ww = nullptr;
136 inwwG = nullptr;
137 gb_inwwG = nullptr;
138 next_to_reduce = 0;
139 // G is already set
140 G1 = nullptr;
141}
142
144// Uses the value of w in the class, and looks at every term of every poly
145// in the marked GB which is > the marked term (in order2) trying to find
146// the next w to use.
147// Returns: true if a w is found
148{
149 // TODO MES: TO WRITE
150 return true;
151}
152
154// GBComputation and Computation inherited routines //
157{
158 // MES: TO WRITE
159}
160
162{
163 if (stop_.always_stop) return; // don't change status
164
165 for (;;) switch (state)
166 {
167 case STATE_compute_w:
168 if (!compute_next_w())
169 {
170 // We are done!
173 return;
174 }
175 inwwG = G->get_parallel_lead_terms(ww);
178 case STATE_do_gb:
179 // Now compute the GB object. If not interrupted, go on:
180 gb_inwwG->start_computation();
181 if (gb_inwwG->status() == COMP_INTERRUPTED)
182 {
184 return;
185 }
186 next_to_reduce = 0;
188 [[fallthrough]];
189 case STATE_reduce:
190 while (next_to_reduce < 0) // TODO: consider the top of the loop
191 {
192 H = G->matrix_remainder(
193 gb_inwwG->get_gb()); // Not quite: need to subtract...
195 }
197 break;
198 case STATE_autoreduce:
199 G->remove_gb();
200 delete G;
201 G1 = static_cast<MarkedGB *>(
202 GBDeclared::create(gb_inwwG->get_initial(-1), H, H, nullptr, nullptr));
204 case STATE_done:
206 return;
207 }
208}
209
211{
212 // MES: TO WRITE
213 return nullptr;
214}
215
217{
218 (void) h;
219 // MES: TO WRITE
220 return nullptr;
221}
222
223const Matrix /* or null */ *GBWalker::get_gb()
224{
225 // MES: TO WRITE
226 return nullptr;
227}
228
229const Matrix /* or null */ *GBWalker::get_mingens()
230{
231 // MES: TO WRITE
232 return nullptr;
233}
234
235const Matrix /* or null */ *GBWalker::get_change()
236{
237 // MES: TO WRITE
238 return nullptr;
239}
240
241const Matrix /* or null */ *GBWalker::get_syzygies()
242{
243 // MES: TO WRITE
244 return nullptr;
245}
246
247const Matrix /* or null */ *GBWalker::get_initial(int nparts)
248{
249 (void) nparts;
250 // MES: TO WRITE
251 return nullptr;
252}
253
255{
256 (void) w;
257 // MES: TO WRITE
258 return nullptr;
259}
260
261const Matrix /* or null */ *GBWalker::matrix_remainder(const Matrix *m)
262{
263 (void) m;
264 // MES: TO WRITE
265 return nullptr;
266}
267
269 const Matrix /* or null */ **result_remainder,
270 const Matrix /* or null */ **result_quotient)
271{
272 (void) m;
273 // MES: TO WRITE, should this be written?
274 *result_remainder = nullptr;
275 *result_quotient = nullptr;
276 ERROR("rawGBMatrixLift not implemented for GB walks");
277 return false;
278}
279
281{
282 (void) m;
283 // MES: TO WRITE
284 return -1;
285}
286
288/* This displays statistical information, and depends on the
289 M2_gbTrace value */
290{
291 (void) o;
292 // MES: TO WRITE
293}
294
295void GBWalker::show() const
296/* This displays statistical information, and depends on the
297 M2_gbTrace value */
298{
299 // MES: TO WRITE
300}
301
303// The computation is complete up through this degree.
304{
305 // MES: TO WRITE
306 return 0;
307}
308
309// Local Variables:
310// compile-command: "make -C $M2BUILDDIR/Macaulay2/e"
311// indent-tabs-mode: nil
312// End:
Computation * set_stop_conditions(M2_bool always_stop, M2_arrayint degree_limit, int basis_element_limit, int syzygy_limit, int pair_limit, int codim_limit, int subring_limit, M2_bool just_min_gens, M2_arrayint length_limit)
Definition comp.cpp:11
enum ComputationStatusCode set_status(enum ComputationStatusCode)
Definition comp.cpp:66
StopConditions stop_
Definition comp.hpp:75
Computation()
Definition comp.cpp:40
Abstract base for long-running, resumable engine computations (GBComputation, ResolutionComputation,...
Definition comp.hpp:70
static GBComputation * choose_gb(const Matrix *m, M2_bool collect_syz, int n_rows_to_keep, M2_arrayint gb_weights, M2_bool use_max_degree, int max_degree, int algorithm, int strategy, int numThreads, int max_reduction_count=10)
Definition comp-gb.cpp:39
static GBComputation * create(const Matrix *m, const Matrix *gb, const Matrix *change, const Matrix *syz)
virtual void show() const
Definition gb-walk.cpp:295
virtual int complete_thru_degree() const
Definition gb-walk.cpp:302
GBComputation * make_gb(const Matrix *M) const
Definition gb-walk.cpp:102
virtual const Matrix * get_initial(int nparts)
Definition gb-walk.cpp:247
virtual const Matrix * get_mingens()
Definition gb-walk.cpp:229
MarkedGB * G1
Definition gb-walk.hpp:89
int next_to_reduce
Definition gb-walk.hpp:85
virtual ~GBWalker()
Definition gb-walk.cpp:91
GBComputation * gb_inwwG
Definition gb-walk.hpp:84
virtual const Matrix * get_parallel_lead_terms(M2_arrayint w)
Definition gb-walk.cpp:254
const FreeModule * F
Definition gb-walk.hpp:60
virtual const Matrix * get_change()
Definition gb-walk.cpp:235
long ** monorder2
Definition gb-walk.hpp:66
virtual bool stop_conditions_ok()
Definition gb-walk.cpp:96
virtual const Matrix * get_syzygies()
Definition gb-walk.cpp:241
GBWalker(const Matrix *gb_under_order1, const MonomialOrdering *order1)
Definition gb-walk.cpp:77
virtual M2_bool matrix_lift(const Matrix *m, const Matrix **result_remainder, const Matrix **result_quotient)
Definition gb-walk.cpp:268
MarkedGB * G
Definition gb-walk.hpp:61
void initialize()
Definition gb-walk.cpp:131
long ** monorder1
Definition gb-walk.hpp:65
const Matrix * H
Definition gb-walk.hpp:86
virtual void text_out(buffer &o) const
Definition gb-walk.cpp:287
enum GBWalker::@204216357340354175217111063216361047022355062066 state
virtual int contains(const Matrix *m)
Definition gb-walk.cpp:280
virtual void remove_gb()
Definition gb-walk.cpp:156
M2_arrayint ww
Definition gb-walk.hpp:82
virtual const Matrix * matrix_remainder(const Matrix *m)
Definition gb-walk.cpp:261
bool compute_next_w()
Definition gb-walk.cpp:143
virtual const Matrix * get_gb()
Definition gb-walk.cpp:223
static GBWalker * create(MarkedGB *G0, long **order1, long **order2)
virtual const PolynomialRing * get_ring() const
Definition gb-walk.cpp:210
@ STATE_reduce
Definition gb-walk.hpp:78
@ STATE_do_gb
Definition gb-walk.hpp:77
@ STATE_compute_w
Definition gb-walk.hpp:76
@ STATE_autoreduce
Definition gb-walk.hpp:79
@ STATE_done
Definition gb-walk.hpp:80
const Matrix * inwwG
Definition gb-walk.hpp:83
const GBRing * R
Definition gb-walk.hpp:59
virtual Computation * set_hilbert_function(const RingElement *h)
Definition gb-walk.cpp:216
virtual void start_computation()
Definition gb-walk.cpp:161
Computation of a reduced GB w.r.t. a marked ordering.
MonomialOrderMatrix(const MonomialOrdering *mo)
MonomialOrdering * toMonomialOrdering() const
long value(int i, long *monom) const
int compare(long *m1, long *m2) const
const long * part(int i) const
Definition gb-walk.cpp:44
int minpart(long *m) const
int facet_compare(long *mon1, long *mon2)
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
GBDeclared — a user-asserted Groebner basis the engine accepts without computing.
@ COMP_DONE
Definition computation.h:60
@ COMP_INTERRUPTED
Definition computation.h:57
ComputationStatusCode / StopConditions / StrategyValues / Algorithms / gbTraceValues — engine-to-inte...
Engine error-reporting primitives: ERROR, INTERNAL_ERROR, error, error_message.
#define Matrix
Definition factory.cpp:14
GBWalker — generic Groebner-walk strategy that transports a basis between term orders.
GBRing and gbvector — the GB-tuned polynomial-ring view used by classical Buchberger code.
const int ERROR
Definition m2-mem.cpp:55
M2_arrayint M2_makearrayint(int n)
Definition m2-types.cpp:6
char M2_bool
Definition m2-types.h:82
Engine-boundary C API for assembling block-level MonomialOrderings from declarative pieces.
Front-end-side description of a monomial ordering as a list of mon_part blocks.