File: gb-walk.cpp

package info (click to toggle)
macaulay2 1.21%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 133,096 kB
  • sloc: cpp: 110,377; ansic: 16,306; javascript: 4,193; makefile: 3,821; sh: 3,580; lisp: 764; yacc: 590; xml: 177; python: 140; perl: 114; lex: 65; awk: 3
file content (284 lines) | stat: -rw-r--r-- 6,736 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/* Copyright 2007, Michael E. Stillman */

#include "gb-walk.hpp"

#include <assert.h>

#include "comp-gb-declared.hpp"
#include "error.h"
#include "gbring.hpp"
#include "interface/computation.h"
#include "interface/monomial-ordering.h"
#include "reducedgb-marked.hpp"

class Computation;
class Matrix;
class buffer;
class RingElement;

class MonomialOrderMatrix
{
  int nvars;
  long **order;

 public:
  MonomialOrderMatrix(const MonomialOrdering *mo);
  ~MonomialOrderMatrix();

  const long *part(int i) const
  {
    assert(i < nvars);
    return order[i];
  }
  int compare(long *m1, long *m2) const;

  int minpart(long *m) const;
  // returns the smallest integer i such that part(j) . m = 0 for j < i

  long value(int i, long *monom) const;
  // return part(i) . monom

  MonomialOrdering *toMonomialOrdering() const;  // TODO

  // Routines needed:
  int facet_compare(long *mon1, long *mon2);  // TODO
};

////////////////////////////////

GBWalker::GBWalker(MarkedGB *G0, long **order1, long **order2)
    : R(G0->get_gb_ring()),
      F(G0->get_ambient_FreeModule()),
      G(G0),
      monorder1(order1),  // or create this from the monomial order?
      monorder2(order2),
      ww(0)
{
  // TODO: need to set what else?
  //
}

GBWalker::GBWalker(const Matrix *gb_under_order1,
                   const MonomialOrdering *order1)
{
}

GBWalker *GBWalker::create(const Matrix *gb_under_order1,
                           const MonomialOrdering *order1)
{
  // TODO MES: TO WRITE
  return new GBWalker(gb_under_order1, order1);
}

GBWalker::~GBWalker()
{
  // TODO MES: TO WRITE
}

bool GBWalker::stop_conditions_ok()
{
  // TODO MES: TO WRITE
  return true;
}

GBComputation *GBWalker::make_gb(const Matrix *M) const
// return the GB of g, keep = 0 or 1.
{
  M2_arrayint weights = M2_makearrayint(R->n_vars());
  for (int i = 0; i < R->n_vars(); i++) weights->array[i] = 1;

  GBComputation *G0 = GBComputation::choose_gb(M,
                                               false,  // collect syz
                                               -1,
                                               weights,
                                               false,
                                               -1,
                                               0,
                                               0
                                               /* , max_reduction_count */
                                               );
  G0->set_stop_conditions(false,
                          NULL,
                          -1,
                          -1,  // syzygy limit
                          -1,
                          -1,
                          -1,
                          false,
                          NULL);
  return G0;
}

void GBWalker::initialize()
{
  // Initialize the local variables of the computation
  state = STATE_compute_w;
  ww = 0;
  inwwG = 0;
  gb_inwwG = 0;
  next_to_reduce = 0;
  // G is already set
  G1 = 0;
}

bool GBWalker::compute_next_w()
// Uses the value of w in the class, and looks at every term of every poly
// in the marked GB which is > the marked term (in order2) trying to find
// the next w to use.
// Returns: true if a w is found
{
  // TODO MES: TO WRITE
  return true;
}

//////////////////////////////////////////////////////
// GBComputation and Computation inherited routines //
//////////////////////////////////////////////////////
void GBWalker::remove_gb()
{
  // MES: TO WRITE
}

void GBWalker::start_computation()
{
  if (stop_.always_stop) return;  // don't change status

  for (;;) switch (state)
      {
        case STATE_compute_w:
          if (!compute_next_w())
            {
              // We are done!
              state = STATE_done;
              set_status(COMP_DONE);
              return;
            }
          inwwG = G->get_parallel_lead_terms(ww);
          gb_inwwG = make_gb(inwwG);
          state = STATE_do_gb;
        case STATE_do_gb:
          // Now compute the GB object.  If not interrupted, go on:
          gb_inwwG->start_computation();
          if (gb_inwwG->status() == COMP_INTERRUPTED)
            {
              set_status(COMP_INTERRUPTED);
              return;
            }
          next_to_reduce = 0;
          state = STATE_reduce;
        case STATE_reduce:
          while (next_to_reduce < 0)  // TODO: consider the top of the loop
            {
              H = G->matrix_remainder(
                  gb_inwwG->get_gb());  // Not quite: need to subtract...
              next_to_reduce++;
            }
          state = STATE_autoreduce;
        case STATE_autoreduce:
          G->remove_gb();
          delete G;
          G1 = static_cast<MarkedGB *>(
              GBDeclared::create(gb_inwwG->get_initial(-1), H, H, 0, 0));
          state = STATE_compute_w;
        case STATE_done:
          set_status(COMP_DONE);
          return;
      }
}

const PolynomialRing *GBWalker::get_ring() const
{
  // MES: TO WRITE
  return 0;
}

Computation /* or null */ *GBWalker::set_hilbert_function(const RingElement *h)
{
  // MES: TO WRITE
  return 0;
}

const Matrix /* or null */ *GBWalker::get_gb()
{
  // MES: TO WRITE
  return 0;
}

const Matrix /* or null */ *GBWalker::get_mingens()
{
  // MES: TO WRITE
  return 0;
}

const Matrix /* or null */ *GBWalker::get_change()
{
  // MES: TO WRITE
  return 0;
}

const Matrix /* or null */ *GBWalker::get_syzygies()
{
  // MES: TO WRITE
  return 0;
}

const Matrix /* or null */ *GBWalker::get_initial(int nparts)
{
  // MES: TO WRITE
  return 0;
}

const Matrix /* or null */ *GBWalker::get_parallel_lead_terms(M2_arrayint w)
{
  // MES: TO WRITE
  return 0;
}

const Matrix /* or null */ *GBWalker::matrix_remainder(const Matrix *m)
{
  // MES: TO WRITE
  return 0;
}

M2_bool GBWalker::matrix_lift(const Matrix *m,
                              const Matrix /* or null */ **result_remainder,
                              const Matrix /* or null */ **result_quotient)
{
  // MES: TO WRITE, should this be written?
  *result_remainder = 0;
  *result_quotient = 0;
  ERROR("rawGBMatrixLift not implemented for GB walks");
  return false;
}

int GBWalker::contains(const Matrix *m)
{
  // MES: TO WRITE
  return -1;
}

void GBWalker::text_out(buffer &o) const
/* This displays statistical information, and depends on the
   M2_gbTrace value */
{
  // MES: TO WRITE
}

void GBWalker::show() const
/* This displays statistical information, and depends on the
   M2_gbTrace value */
{
  // MES: TO WRITE
}

int GBWalker::complete_thru_degree() const
// The computation is complete up through this degree.
{
  // MES: TO WRITE
  return 0;
}

// Local Variables:
// compile-command: "make -C $M2BUILDDIR/Macaulay2/e"
// indent-tabs-mode: nil
// End: