Macaulay2 Engine
Loading...
Searching...
No Matches
comp-gb.cpp
Go to the documentation of this file.
1// Copyright 2004 Michael E. Stillman.
2
3#include "comp-gb.hpp"
4
5#include "gb-homog2.hpp"
6#include "gb-sugarless.hpp"
7#include "gb-toric.hpp"
8#include "gauss.hpp"
9#include "hermite.hpp"
10#include "gb-default.hpp"
11#include "gbweight.hpp"
12#include "comp-gb-proxy.hpp"
13#include "text-io.hpp"
14#include "finalize.hpp"
15#include "util.hpp"
16
18 M2_bool collect_syz,
19 int n_rows_to_keep,
20 M2_arrayint gb_weights,
21 int strategy,
22 M2_bool use_max_degree,
23 int max_degree,
24 int numThreads);
25
26// Found in "gb-f4/GBF4Interface.hpp"
28 const std::vector<int>& weights,
29 int strategy,
30 int numThreads
31 );
32
35{
36 o << "-- a raw Groebner basis computation --";
37}
38
40 M2_bool collect_syz,
41 int n_rows_to_keep,
42 M2_arrayint gb_weights,
43 M2_bool use_max_degree,
44 int max_degree,
45 int algorithm,
46 int strategy,
47 int numThreads,
48 int max_reduction_count)
49{
50 const Ring *R1 = m->get_ring();
51 const PolynomialRing *R2 = R1->cast_to_PolynomialRing();
52
53 std::vector<int> weights; // used in createParallelF4GB
54 if (R2 == nullptr)
55 {
56 // Look for the correct computation type here.
57 if (R1 == globalZZ)
58 {
59 return new HermiteComputation(m, collect_syz, n_rows_to_keep);
60 }
61 if (R1->is_field())
62 {
63 return new GaussElimComputation(m, collect_syz, n_rows_to_keep);
64 }
65#ifdef DEVELOPMENT
66#warning "handle non polynomial rings"
67#endif
68 ERROR("GB computation for non-polynomial rings not yet re-implemented");
69 return nullptr;
70 }
71
72// const PolynomialRing *R = R2->get_flattened_ring();
73// bool is_graded = (R->is_graded() && m->is_homogeneous());
74// bool ring_is_base = R->is_basic_ring();
75// bool base_is_ZZ = R->getCoefficientRing()->is_ZZ();
76#ifdef DEVELOPMENT
77#warning "NOT QUITE!! Need to know if it is ZZ or QQ"
78#warning "unused variables commented out"
79#endif
80 // bool base_is_field = !R->getCoefficientRing()->is_ZZ();
81
83
84 switch (algorithm)
85 {
86 case 4:
88 collect_syz,
89 n_rows_to_keep,
90 gb_weights,
91 strategy,
92 use_max_degree,
93 max_degree);
94 break;
95 case 5:
97 collect_syz,
98 n_rows_to_keep,
99 gb_weights,
100 strategy,
101 use_max_degree,
102 max_degree);
103 break;
104 case 6:
105 result = createF4GB(m,
106 collect_syz,
107 n_rows_to_keep,
108 gb_weights,
109 strategy,
110 use_max_degree,
111 max_degree,
112 numThreads);
113 break;
114 case 7:
116 collect_syz,
117 n_rows_to_keep,
118 gb_weights,
119 strategy,
120 use_max_degree,
121 max_degree);
122 break;
123 case 8:
124 ERROR("Algorithm => Test has been removed from M2");
125 return nullptr;
126 case 9:
127 // new GBF4 algorithm
128 weights = M2_arrayint_to_stdvector<int>(gb_weights);
130 weights,
131 strategy,
132 numThreads);
133 break;
134 default:
136 collect_syz,
137 n_rows_to_keep,
138 gb_weights,
139 strategy,
140 use_max_degree,
141 max_degree,
142 max_reduction_count);
143 break;
144 }
146 return result != nullptr ? new GBProxy(result) : nullptr;
147
148#if 0
149// if (is_graded)
150// return GB_comp::create(m,
151// collect_syz,
152// n_rows_to_keep,
153// strategy,
154// use_max_degree,
155// max_degree);
156//
157// return 0;
158#endif
159#if 0
160// if (base_is_ZZ)
161// {
162// if (ring_is_base)
163// {
164//
165// return HermiteComputation::create(m,
166// collect_syz,
167// collect_change,
168// n_rows_to_keep);
169// return 0;
170// }
171// // Question: should we separate between the graded, nongraded versions?
172// return GBZZ::create(m,
173// collect_syz,
174// collect_change,
175// n_rows_to_keep);
176// return 0;
177// }
178// else
179// {
180// // Base is a field
181// if (ring_is_base)
182// {
183// return GaussElimComputation::create(m,
184// collect_syz,
185// collect_change,
186// n_rows_to_keep);
187// // This should be fraction free
188// return 0;
189// }
190// // Also allow the user to choose between them.
191// if (is_graded)
192// return GB_comp::create(m,
193// collect_syz,
194// n_rows_to_keep,
195// strategy,
196// use_max_degree,
197// max_degree);
198// return GB_inhom_comp::create(m,
199// collect_syz,
200// collect_change,
201// n_rows_to_keep,
202// strategy);
203// return 0;
204// }
205#endif
206}
207
209 const RingElement *h)
210// The default version returns an error saying that Hilbert functions cannot be
211// used.
212{
213 (void) h;
214 ERROR("Hilbert function use is not implemented for this GB algorithm");
215 return nullptr;
216}
217
219 M2_arrayint w)
220{
221 (void) w;
222 ERROR(
223 "Cannot compute parallel lead terms for this kind of Groebner "
224 "computation");
225 return nullptr;
226}
227
228// Local Variables:
229// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
230// indent-tabs-mode: nil
231// End:
Computation()
Definition comp.cpp:40
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 Computation * set_hilbert_function(const RingElement *h)
Definition comp-gb.cpp:208
virtual ~GBComputation()
Definition comp-gb.cpp:33
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
friend class GBProxy
Definition comp-gb.hpp:71
void text_out(buffer &o) const override
Definition comp-gb.cpp:34
virtual const Matrix * get_parallel_lead_terms(M2_arrayint w)
Definition comp-gb.cpp:218
base class for Groebner basis computations.
Definition comp-gb.hpp:69
static GBinhom_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)
Gaussian elimination class. To be rewritten.
Definition gauss.hpp:59
Slow Hermite normal form computation over ZZ. Replace.
Definition hermite.hpp:56
const Ring * get_ring() const
Definition matrix.hpp:134
Abstract base for the engine's polynomial-ring hierarchy.
Definition polyring.hpp:96
bool is_field() const
Definition ring.cpp:68
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
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
static binomialGB_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)
Definition gb-toric.cpp:993
static gbA * 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, int max_reduction_count)
GBProxy — legacy indirection wrapper around another GBComputation (deprecated).
GBComputation * createGBF4Interface(const Matrix *m, const std::vector< int > &weights, int strategy, int numThreads)
GBComputation * createF4GB(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, int numThreads)
GBComputation — abstract base of every Groebner-basis algorithm in the engine.
#define Matrix
Definition factory.cpp:14
void intern_GB(GBComputation *G)
Definition finalize.cpp:112
intern_* helpers that register long-lived engine objects with bdwgc finalisers.
RingZZ * globalZZ
Definition relem.cpp:13
GaussElimComputation — Gaussian elimination GB / submodule strategy over a field.
gbA — the engine's default Buchberger-style Groebner-basis algorithm.
GB_comp — Buchberger GB specialised to homogeneous input.
GBinhom_comp — Buchberger GB without the sugar heuristic, primarily for inhomogeneous input.
binomialGB_comp — Buchberger GB specialised to binomial / toric ideals.
GBWeight — packed-weight evaluator that drives S-pair selection.
HermiteComputation — Hermite normal form over ZZ, the ZZ-analogue of GaussElimComputation.
const int ERROR
Definition m2-mem.cpp:55
VALGRIND_MAKE_MEM_DEFINED & result(result)
char M2_bool
Definition m2-types.h:82
Text-formatting helpers layered on buffer: bignum print, line wrapping, M2_gbTrace-gated emit.
std::vector< T > M2_arrayint_to_stdvector(M2_arrayint arr)
Definition util.hpp:96
Conversion helpers between M2 boundary types and standard C++ containers.