Macaulay2 Engine
Loading...
Searching...
No Matches
groebner.h
Go to the documentation of this file.
1/*******************************************
2 * Computation routines for Groebner bases *
3 *******************************************/
4
5// FIXME: this header is based on what is defined in groebner.cpp,
6// but the declarations in engine.h don't seem to match
7
8#ifndef _groebner_h_
9# define _groebner_h_
10
54
55# include "engine-includes.hpp"
57
58// TODO: fix this
59# if defined(__cplusplus)
60class Computation;
61class FreeModule;
62class Matrix;
63class Ring;
64class RingElement;
66class MutableMatrix;
67class RingMap;
68# else
69typedef struct Computation Computation;
70typedef struct FreeModule FreeModule;
71typedef struct Matrix Matrix;
73typedef struct MutableMatrix MutableMatrix;
74typedef struct Ring Ring;
75typedef struct RingElement RingElement;
76typedef struct RingMap RingMap;
77# endif
78
82
83# if defined(__cplusplus)
84extern "C" {
85# endif
86
87void test_over_RR_or_CC(const Ring *R);
88
90// F4 routines //
93 M2_arrayint slanted_degree_limit,
94 M2_arrayint length_limit);
95/* connected: rawMinimalBetti */
96
97const RingElement /* or null */ *IM2_Matrix_Hilbert(const Matrix *M);
98/* This routine computes the numerator of the Hilbert series
99 for coker leadterms(M), using the degrees of the rows of M.
100 NULL is returned if the ring is not appropriate for
101 computing Hilbert series, or the computation was interrupted. */
102
103const Matrix *rawKernelOfGB(const Matrix *M);
104/* Assuming that the columns of M form a GB, this routine computes
105 a Groebner basis of the kernel of these elements, using an
106 appropriate Schreyer order on the source of M. */
107
111Computation /* or null */ *IM2_GB_make(
112 const Matrix *m,
113 M2_bool collect_syz,
114 int n_rows_to_keep,
115 M2_arrayint gb_weights,
116 M2_bool use_max_degree,
117 int max_degree,
118 int algorithm,
119 int strategy,
120 int max_reduction_count); /* drg: connected rawGB */
121
122Computation /* or null */ *IM2_res_make(const Matrix *m,
123 M2_bool resolve_cokernel,
124 int max_level,
125 M2_bool use_max_slanted_degree,
126 int max_slanted_degree,
127 int algorithm,
128 int strategy,
129 M2_bool parallelizeByDegree);
130
131/* rawGBSetHilbertFunction */
133 const RingElement *h);
134
135/* rawGBForce */
136Computation /* or null */ *IM2_GB_force(
137 const Matrix *m, /* trimmed or minimal gens, may be the same as gb */
138 const Matrix *gb,
139 const Matrix *change, /* same number of columns as 'gb', if not 0 */
140 const Matrix *syz); /* possibly 0 too, otherwise same rows as change */
141
142/* rawMarkedGB */
143Computation /* or null */ *rawMarkedGB(
144 const Matrix *leadterms,
145 const Matrix *m, /* trimmed or minimal gens, may be the same as gb */
146 const Matrix *gb,
147 const Matrix *change, /* same number of columns as 'gb', if not 0 */
148 const Matrix *syz); /* possibly 0 too, otherwise same rows as change */
149
150/* Create a GB algorithm which will compute using the generic Groebner walk algorithm
151 Input: gb: a matrix which, under order1, would be a Groebner basis, except that
152 'gb' is a matrix over a polynomial ring whose order is 'order2'.
153 order1: a monomial ordering
154 Output: a Groebner basis computation object which will compute a GB of gb wrt
155 order2, using the Geneeric Groebner Walk algorithm of ...
156 Assumptions: the base ring is a polynomial ring over a field, with NO quotient elements
157 */
158Computation /* or null */ *rawGroebnerWalk(const Matrix *gb,
159 const MonomialOrdering *order1);
160
162 Computation *G,
163 M2_bool always_stop,
164 M2_arrayint degree_limit,
165 int basis_element_limit,
166 int syzygy_limit,
167 int pair_limit,
168 int codim_limit,
169 int subring_limit,
170 M2_bool just_min_gens,
171 M2_arrayint length_limit); /* TODO */
172/* LongPolynomial, Sort, Primary, Inhomogeneous, Homogeneous */
173/* Res: SortStrategy, 0, 1, 2, 3 ?? */
174
176/* start or continue the computation */
177
179
180int rawStatus2(Computation *C);
181void rawShowComputation(const Computation *C);
182
183const Matrix /* or null */ *rawGBGetMatrix(Computation *C);
184/* Get the minimal, auto-reduced GB of a GB computation.
185 Each call to this will produce a different raw matrix */
186
187const Matrix /* or null */ *rawGBMinimalGenerators(Computation *C);
188/* Yields a matrix whose columns form a minimal generating set
189 for the ideal or submodule, as computed so far. In the
190 inhomogeneous case, this yields a generating set which is
191 sometimes smaller than the entire Groebner basis. */
192
193const Matrix /* or null */ *rawGBChangeOfBasis(Computation *C);
194/* Yields the change of basis matrix from the Groebner basis to
195 the original generators, at least if n_rows_to_keep was set
196 when creating the GB computation. This matrix, after the
197 computation has run to completion, should satisfy:
198 (original matrix) = (GB matrix) * (change of basis matrix). */
199
200const Matrix /* or null */ *rawGBGetLeadTerms(Computation *C, int nparts);
201
202const Matrix /* or null */ *rawGBGetParallelLeadTerms(Computation *C,
203 M2_arrayint w);
204
205const Matrix /* or null */ *rawGBSyzygies(Computation *C);
206/* Yields a matrix containing the syzygies computed so far
207 via the GB computation C, assuming that 'collect_syz' was
208 set when the computation was created. If 'n_rows_to_keep' was
209 set to a non-negative integer, then only that many rows of each
210 syzygy are kept. */
211
212/* rawGBMatrixRemainder */
213const Matrix /* or null */ *rawGBMatrixRemainder(Computation *C,
214 const Matrix *m);
215
216/* rawGBMatrixLift: false is returned if there is an error or if the
217 remainder is NON-zero */
219 const Matrix *m,
220 const Matrix /* or null */ **result_remainder,
221 const Matrix /* or null */ **result_quotient);
222
223/* rawGBContains: given a Groebner basis computation C and matrix m, returns:
224 -2 for errors
225 -1 for containment of span(m) in span(C)
226 i for the smallest index of a column of m not contained in span(C) */
227int IM2_GB_contains(Computation *C, const Matrix *m);
228
229/*******************************************
230 * Noncommutative Groebner bases ***********
231 *******************************************/
232
233/* Returns a 2-sided GB of the 2-sided ideal from the one-row matrix 'input'
234 computed up to and including degree 'maxdeg'. This 'maxdeg' is the heft
235 degree (in the case of multigradings). 'strategy': is an integer whose
236 various bits encode stratgy options Assumptions:
237 1. input is a one row matrix, whose entries are the generators of a 2-sided
238 ideal.
239 2. If the computation is interrupted, we return the elements we have
240 constructed so far.
241 3. use gbTrace as usual to get verbose messages during computation.
242 Not done yet:
243 writing GB elements in terms of original generators.
244 We will need a new function
245 Strategy bits:
246 bits 0..3: choice of reduction heap strategy.
247*/
248const Matrix *rawNCGroebnerBasisTwoSided(const Matrix *input,
249 int maxdeg,
250 int strategy);
251
252const Matrix *rawNCReductionTwoSided(const Matrix *toBeReduced,
253 const Matrix *reducers);
254
255const Matrix *rawNCBasis(const Matrix *gb2SidedIdeal,
256 M2_arrayint lo_degree,
257 M2_arrayint hi_degree,
258 int limit);
259
260/*******************************************
261 *******************************************
262 *******************************************/
263
264const Matrix /* or null */ *rawResolutionGetMatrix(Computation *C, int level);
265
267 int level,
268 int degree);
269
271 const Ring *R,
272 int level);
273// Perhaps a HACK that might change.
274// First: C must be a nonminimal res computation, over QQ M.
275// Second: R must be a polynomial ring with the same monoid M as C's,
276// and the coefficient ring must be either RR, or ZZ/p, where p is the (a)
277// prime being used in the computation.
278
280 Computation *C,
281 const Ring *KK, // should be RR, or a finite field used in C.
282 int level,
283 int degree);
284
285const FreeModule /* or null */ *rawResolutionGetFree(Computation *C, int level);
286
287/* TODO */
289 int *complete_up_through_this_degree,
290 int *complete_up_through_this_level);
291
292/* TODO */
294 Computation *C,
295 int level,
296 M2_bool minimize,
297 int *complete_up_through_this_degree);
298
300/* see engine.h for description of what 'type' should be */
301
302M2_string IM2_GB_to_string(Computation *C);
303/* TODO */
304
305unsigned int rawComputationHash(const Computation *C);
306
307Matrix /* or null */ *rawSubduction(int numparts,
308 const Matrix *M,
309 const RingMap *F,
310 Computation *C);
311
312Matrix /* or null */ *rawSubduction1(int numparts,
313 const Ring *rawT,
314 const Ring *rawS,
315 const Matrix *m,
316 const RingMap *inclusionAmbient,
317 const RingMap *fullSubstitution,
318 const RingMap *substitutionInclusion,
319 Computation *rawGBI,
320 Computation *rawGBReductionIdeal);
321
322void rawDisplayMatrixStream(const Matrix *inputMatrix);
323
324/* rawMGB: interface to mathicgb for computing a Groebner basis of an ideal
325 in a polynomial ring over a finite prime field.
326 reducer: 0 is ClassicReducer, 1 is MatrixReducer */
327const Matrix *rawMGB(
328 const Matrix *input,
329 int reducer,
330 int spairGroupSize, // a value of 0 means let the algorithm choose
331 int nthreads,
332 M2_string logging);
333
334# if defined(__cplusplus)
335}
336# endif
337
338#endif /* _groebner_h_ */
339
340// Local Variables:
341// indent-tabs-mode: nil
342// 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
Abstract base class for mutable matrices over an arbitrary engine Ring, the in-place counterpart of t...
Definition mat.hpp:79
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
const Monoid * M
Definition ringmap.hpp:93
const Ring * R
Definition ringmap.hpp:89
Engine-side ring homomorphism: stores, for each source-ring variable, the target-ring element it maps...
Definition ringmap.hpp:60
ComputationStatusCode
Definition computation.h:53
ComputationStatusCode / StopConditions / StrategyValues / Algorithms / gbTraceValues — engine-to-inte...
Engine-wide include prelude — a single point of truth for portability shims.
#define Matrix
Definition factory.cpp:14
void gb(IntermediateBasis &F, int n)
const RingElement * IM2_Matrix_Hilbert(const Matrix *M)
Definition groebner.cpp:58
Matrix * rawSubduction(int numparts, const Matrix *M, const RingMap *F, Computation *C)
Definition groebner.cpp:649
const Matrix * rawGBMinimalGenerators(Computation *C)
Definition groebner.cpp:338
unsigned int rawComputationHash(const Computation *C)
Definition groebner.cpp:648
const Matrix * rawNCReductionTwoSided(const Matrix *toBeReduced, const Matrix *reducers)
Definition groebner.cpp:977
int IM2_GB_contains(Computation *C, const Matrix *m)
Definition groebner.cpp:470
const Matrix * rawGBMatrixRemainder(Computation *C, const Matrix *m)
Definition groebner.cpp:433
MutableMatrix * rawResolutionGetMatrix2(Computation *C, int level, int degree)
Definition groebner.cpp:502
Computation * IM2_res_make(const Matrix *m, M2_bool resolve_cokernel, int max_level, M2_bool use_max_slanted_degree, int max_slanted_degree, int algorithm, int strategy, M2_bool parallelizeByDegree)
Definition groebner.cpp:124
Computation * rawStartComputation(Computation *C)
Definition groebner.cpp:264
Computation * IM2_GB_set_hilbert_function(Computation *C, const RingElement *h)
Definition groebner.cpp:161
const Matrix * rawResolutionGetMatrix(Computation *C, int level)
Definition groebner.cpp:486
enum ComputationStatusCode IM2_Resolution_status_level(Computation *C, int level, M2_bool minimize, int *complete_up_through_this_degree)
Definition groebner.cpp:593
enum ComputationStatusCode rawStatus1(Computation *C)
Definition groebner.cpp:317
int rawStatus2(Computation *C)
Definition groebner.cpp:318
void rawShowComputation(const Computation *C)
Definition groebner.cpp:319
const Matrix * rawNCGroebnerBasisTwoSided(const Matrix *input, int maxdeg, int strategy)
Definition groebner.cpp:946
MutableMatrix * rawResolutionGetMutableMatrix2B(Computation *C, const Ring *KK, int level, int degree)
Definition groebner.cpp:543
MutableMatrix * rawResolutionGetMutableMatrixB(Computation *C, const Ring *R, int level)
Definition groebner.cpp:520
Computation * IM2_GB_make(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 max_reduction_count)
Definition groebner.cpp:90
int IM2_Resolution_status(Computation *C, int *complete_up_through_this_degree, int *complete_up_through_this_level)
Definition groebner.cpp:579
const Matrix * rawKernelOfGB(const Matrix *M)
Definition groebner.cpp:74
const Matrix * rawGBGetLeadTerms(Computation *C, int nparts)
Definition groebner.cpp:379
const Matrix * rawGBGetMatrix(Computation *C)
Definition groebner.cpp:320
const FreeModule * rawResolutionGetFree(Computation *C, int level)
Definition groebner.cpp:563
void test_over_RR_or_CC(const Ring *R)
Definition groebner.cpp:38
Computation * rawMarkedGB(const Matrix *leadterms, const Matrix *m, const Matrix *gb, const Matrix *change, const Matrix *syz)
Definition groebner.cpp:200
const Matrix * rawGBSyzygies(Computation *C)
Definition groebner.cpp:412
Computation * rawGroebnerWalk(const Matrix *gb, const MonomialOrdering *order1)
Definition groebner.cpp:218
void rawDisplayMatrixStream(const Matrix *inputMatrix)
Definition groebner.cpp:698
const Matrix * rawGBChangeOfBasis(Computation *C)
Definition groebner.cpp:358
Computation * IM2_GB_force(const Matrix *m, const Matrix *gb, const Matrix *change, const Matrix *syz)
Definition groebner.cpp:183
M2_arrayintOrNull rawResolutionBetti(Computation *C, int type)
Definition groebner.cpp:617
M2_string IM2_GB_to_string(Computation *C)
Definition groebner.cpp:633
Matrix * rawSubduction1(int numparts, const Ring *rawT, const Ring *rawS, const Matrix *m, const RingMap *inclusionAmbient, const RingMap *fullSubstitution, const RingMap *substitutionInclusion, Computation *rawGBI, Computation *rawGBReductionIdeal)
Definition groebner.cpp:669
M2_bool IM2_GB_matrix_lift(Computation *C, const Matrix *m, const Matrix **result_remainder, const Matrix **result_quotient)
Definition groebner.cpp:450
Computation * IM2_Computation_set_stop(Computation *G, 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 groebner.cpp:231
const Matrix * rawNCBasis(const Matrix *gb2SidedIdeal, M2_arrayint lo_degree, M2_arrayint hi_degree, int limit)
M2_arrayint rawMinimalBetti(Computation *G, M2_arrayint slanted_degree_limit, M2_arrayint length_limit)
const Matrix * rawGBGetParallelLeadTerms(Computation *C, M2_arrayint w)
Definition groebner.cpp:395
const Matrix * rawMGB(const Matrix *input, int reducer, int spairGroupSize, int nthreads, M2_string logging)
Definition groebner.cpp:778
M2_arrayint M2_arrayintOrNull
Definition m2-types.h:99
char M2_bool
Definition m2-types.h:82
tbb::flow::graph G
Front-end-side description of a monomial ordering as a list of mon_part blocks.