Macaulay2 Engine
Loading...
Searching...
No Matches
comp-gb-declared.cpp
Go to the documentation of this file.
3#include "matrix.hpp"
4#include "reducedgb.hpp"
5#include "polyring.hpp"
6
8 const Matrix *gb,
9 const Matrix *change,
10 const Matrix *syz0)
11 : trimmed_gens(m0), syz(syz0)
12{
14 const Ring *R = gb->get_ring();
16 GBRing *GR = P->get_gb_ring();
17 const Ring *K = GR->get_flattened_coefficients();
18
19 const FreeModule *F = m0->rows();
20 const FreeModule *Fsyz = change->rows();
21
22 G = ReducedGB::create(P, F, Fsyz);
23
24 // Now add in the elements
25 VECTOR(POLY) elems;
26 for (int i = 0; i < gb->n_cols(); i++)
27 {
28 POLY g;
29 ring_elem denom1, denom2, u, v;
30
31 if (gb->elem(i) == nullptr)
32 continue; // Do not even consider including 0 elements.
33 g.f = P->translate_gbvector_from_vec(F, gb->elem(i), denom1);
34 g.fsyz = P->translate_gbvector_from_vec(Fsyz, change->elem(i), denom2);
35
36 K->syzygy(denom1, denom2, u, v);
38 K->negate_to(v);
40
41 elems.push_back(g);
42 }
43 G->minimalize(elems);
44}
45
47 const Matrix *m0,
48 const Matrix *gb,
49 const Matrix *change,
50 const Matrix *syz0)
51 : trimmed_gens(m0), syz(syz0)
52{
54 const Ring *R = gb->get_ring();
56 GBRing *GR = P->get_gb_ring();
57 const Ring *K = GR->get_flattened_coefficients();
58
59 const FreeModule *F = m0->rows();
60 const FreeModule *Fsyz = change->rows();
61
62 MarkedGB *G0 = MarkedGB::create(P, F, Fsyz);
63 G = G0;
64
65 // Now add in the elements
66 VECTOR(POLY) elems;
67 VECTOR(gbvector *) leads;
68 for (int i = 0; i < gb->n_cols(); i++)
69 {
70 POLY g;
71 gbvector *lead;
72 ring_elem denom1, denom2, denom3, u, v;
73
74 if (gb->elem(i) == nullptr)
75 continue; // Do not even consider including 0 elements.
76 g.f = P->translate_gbvector_from_vec(F, gb->elem(i), denom1);
77 g.fsyz = P->translate_gbvector_from_vec(Fsyz, change->elem(i), denom2);
78 lead = P->translate_gbvector_from_vec(F, leadterms->elem(i), denom3);
79 K->syzygy(denom1, denom2, u, v);
81 K->negate_to(v);
83
84 elems.push_back(g);
85 leads.push_back(lead);
86 }
87 G0->add_marked_elems(leads, elems, true);
88}
89
91 const Matrix *gb,
92 const Matrix *change,
93 const Matrix *syz)
94{
95 // Check:
96 // the rings are all the same, and all are not NULL.
97 // m->rows(), gb->rows() are the same
98 // change->rows(), syz->rows() are the same.
99 assert(m != 0 && gb != 0 && change != 0 && syz != 0);
100 const Ring *R = gb->get_ring();
101 if (R != m->get_ring() || R != change->get_ring() || R != syz->get_ring())
102 {
103 ERROR("expected the same ring");
104 return nullptr;
105 }
106
108 if (P == nullptr)
109 {
110 ERROR("declaring a GB requires a polynomial ring");
111 return nullptr;
112 }
113 // Then: create and return the object
114 return new GBDeclared(m, gb, change, syz);
115}
116
118 const Matrix *m,
119 const Matrix *gb,
120 const Matrix *change,
121 const Matrix *syz)
122{
123 // Check:
124 // the rings are all the same, and all are not NULL.
125 // m->rows(), gb->rows() are the same
126 // change->rows(), syz->rows() are the same.
127 assert(leadterms != 0 && m != 0 && gb != 0 && change != 0 && syz != 0);
128 const Ring *R = gb->get_ring();
129 if (R != m->get_ring() || R != leadterms->get_ring() ||
130 R != change->get_ring() || R != syz->get_ring())
131 {
132 ERROR("expected the same ring");
133 return nullptr;
134 }
135
137 if (P == nullptr)
138 {
139 ERROR("declaring a GB requires a polynomial ring");
140 return nullptr;
141 }
142 if (leadterms->n_rows() != gb->n_rows() ||
143 leadterms->n_cols() != gb->n_cols())
144 {
145 ERROR(
146 "expected same number of lead terms as marked Groebner basis "
147 "elements");
148 return nullptr;
149 }
150 // Then: create and return the object
151 return new GBDeclared(leadterms, m, gb, change, syz);
152}
153
154// Local Variables:
155// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
156// indent-tabs-mode: nil
157// End:
enum ComputationStatusCode set_status(enum ComputationStatusCode)
Definition comp.cpp:66
Engine-side free module R^n over a Ring.
Definition freemod.hpp:66
const Matrix * trimmed_gens
ReducedGB * G
const Matrix * syz
static GBComputation * create(const Matrix *m, const Matrix *gb, const Matrix *change, const Matrix *syz)
GBDeclared(const Matrix *m0, const Matrix *gb, const Matrix *change, const Matrix *syz0)
void gbvector_mult_by_coeff_to(gbvector *f, ring_elem u)
Definition gbring.cpp:557
const Ring * get_flattened_coefficients() const
Definition gbring.hpp:231
Polynomial-ring view tuned for the inner loop of classical Buchberger Groebner-basis computations.
Definition gbring.hpp:120
virtual void add_marked_elems(const VECTOR(gbvector *) &leadterms, const VECTOR(POLY) &polys0, bool auto_reduced)
friend ReducedGB * ReducedGB::create(const PolynomialRing *originalR0, const FreeModule *F0, const FreeModule *Fsyz0, const GBWeight *wt0)
Computation of a reduced GB w.r.t. a marked ordering.
const Ring * get_ring() const
Definition matrix.hpp:134
ring_elem elem(int i, int j) const
Definition matrix.cpp:307
int n_cols() const
Definition matrix.hpp:147
int n_rows() const
Definition matrix.hpp:146
const FreeModule * rows() const
Definition matrix.hpp:144
virtual GBRing * get_gb_ring() const
Definition polyring.hpp:276
virtual gbvector * translate_gbvector_from_vec(const FreeModule *F, const vec v, ring_elem &result_denominator) const =0
Abstract base for the engine's polynomial-ring hierarchy.
Definition polyring.hpp:96
static ReducedGB * create(const PolynomialRing *originalR0, const FreeModule *F0, const FreeModule *Fsyz0, const GBWeight *wt0=nullptr)
Definition reducedgb.cpp:11
void negate_to(ring_elem &f) const
Definition ring.cpp:210
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
virtual void syzygy(const ring_elem a, const ring_elem b, ring_elem &x, ring_elem &y) const =0
xxx xxx xxx
Definition ring.hpp:102
GBDeclared — a user-asserted Groebner basis the engine accepts without computing.
@ COMP_DONE
Definition computation.h:60
#define Matrix
Definition factory.cpp:14
void gb(IntermediateBasis &F, int n)
const int ERROR
Definition m2-mem.cpp:55
Matrix — the engine's immutable homomorphism F -> G between free modules.
#define VECTOR(T)
Definition newdelete.hpp:78
#define POLY(q)
Definition poly.cpp:23
PolynomialRing — abstract polynomial-ring base, the engine's most-reused class.
ReducedGB — abstract base for the canonicalising reduction pass that follows GB computation.
gbvector * fsyz
Definition gbring.hpp:99
gbvector * f
Definition gbring.hpp:98