Macaulay2 Engine
Loading...
Searching...
No Matches

◆ initialize()

void gbA::initialize ( const Matrix * m,
int csyz,
int nsyz,
M2_arrayint gb_weights,
int strat,
int max_reduction_count0 )
private

Definition at line 99 of file gb-default.cpp.

105{
106 // max_reduction_count: default was 10
107 // 1 is best possible for 3-anderbuch!
108 // 5 is: (114.64 sec, 494 MB)
109 // 10 is best so far (125.33 sec, 527 MB virtual).
110 // 50 is faster/smaller than 100, and 1000 was awful, on 3-andersbuch
111
112 ringtable = nullptr;
113 ringtableZZ = nullptr;
115
116 max_reduction_count = max_reduction_count0;
117
118 const PolynomialRing *origR = m->get_ring()->cast_to_PolynomialRing();
119 if (origR == nullptr)
120 {
121 ERROR("ring is not a polynomial ring");
122 // MES: throw an error here.
123 assert(0);
124 }
125 originalR = origR;
126 R = origR->get_gb_ring();
127 weightInfo_ = new GBWeight(m->rows(), gb_weights0);
128 gb_weights = weightInfo_->get_weights();
129
130 _nvars = R->get_flattened_monoid()->n_vars();
131 _coeff_type = origR->coefficient_type();
133
134 is_local_gb = (origR->getMonoid()->numNonTermOrderVariables() > 0);
135
136 spair_stash = new stash("gbA spairs", sizeof(spair));
137 gbelem_stash = new stash("gbA elems", sizeof(gbelem));
138 exp_size = EXPONENT_BYTE_SIZE(R->n_vars() + 2);
139 lcm_stash = new stash("gbA lead monoms", exp_size);
140
141 if (nsyz < 0 || nsyz > m->n_cols()) nsyz = m->n_cols();
142 n_rows_per_syz = nsyz;
143
144 _F = m->rows();
146
147 S = new SPairSet;
148 first_in_degree = 0;
149 n_syz = 0;
151 n_gens_left = 0;
152 n_subring = 0;
153
154 _strategy = strat;
155 _collect_syz = csyz;
156 _is_ideal = (_F->rank() == 1 && csyz == 0);
157 if (R->is_weyl_algebra()) _is_ideal = false;
158
159 use_hilb = false;
160 hilb_new_elems = false;
162 n_saved_hilb = 0;
163 hf_orig = nullptr;
164 hf_diff = nullptr;
165
166 this_degree = _F->lowest_primary_degree() - 1;
167 npairs = 0;
170
172 stats_ntail = 0;
173 stats_npairs = 0;
174 stats_ngb = 0;
175 stats_ngcd1 = 0;
176 stats_nretired = 0;
177
178 divisor_previous = -1;
180
181 // ZZZZ split
182 lookup = nullptr;
183 lookupZZ = nullptr;
184 if (over_ZZ())
185 lookupZZ = MonomialTableZZ::make(R->n_vars());
186 else
187 {
188 lookup = MonomialTable::make(R->n_vars());
189 }
190
192 minimal_gb_valid = true;
193
194 if (originalR->is_quotient_ring())
195 {
196 ringtable = originalR->get_quotient_MonomialTable();
197 ringtableZZ = originalR->get_quotient_MonomialTableZZ();
198
199 first_gb_element = originalR->n_quotients();
200 for (int i = 0; i < first_gb_element; i++)
201 {
202 gbvector *f = const_cast<gbvector *>(originalR->quotient_gbvector(i));
203 gbelem *g = gbelem_ring_make(f);
204 gb.push_back(g);
205 forwardingZZ.push_back(-1);
206 }
207 }
208 for (int i = 0; i < m->n_cols(); i++)
209 {
210 ring_elem denom;
211 gbvector *f = originalR->translate_gbvector_from_vec(_F, (*m)[i], denom);
212 spair *p = new_gen(i, f, denom);
213 if (p != nullptr)
214 {
216 }
217 }
218
219 state = STATE_NEWDEGREE; // will be changed if hilb fcn is used
222 ar_j = ar_i + 1;
224}
enum ComputationStatusCode set_status(enum ComputationStatusCode)
Definition comp.cpp:66
FreeModule * sub_space(int n) const
Definition freemod.cpp:197
const Ring * get_ring() const
Definition matrix.hpp:134
int n_cols() const
Definition matrix.hpp:147
const FreeModule * rows() const
Definition matrix.hpp:144
const FreeModule * cols() const
Definition matrix.hpp:145
static MonomialTable * make(int nvars)
Definition montable.cpp:61
static MonomialTableZZ * make(int nvars)
virtual int n_fraction_vars() const
Definition polyring.hpp:295
virtual GBRing * get_gb_ring() const
Definition polyring.hpp:276
virtual const Monoid * getMonoid() const
Definition polyring.hpp:282
CoefficientType coefficient_type() const
Definition polyring.hpp:191
static ReducedGB * create(const PolynomialRing *originalR0, const FreeModule *F0, const FreeModule *Fsyz0, const GBWeight *wt0=nullptr)
Definition reducedgb.cpp:11
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
int n_gens_left
MonomialTable * ringtable
int n_pairs_computed
MonomialTable * lookup
GBRing * R
int first_gb_element
int stats_ngb
Ring::CoefficientType _coeff_type
const PolynomialRing * originalR
stash * gbelem_stash
int n_subring
int _strategy
int _nvars
int divisor_previous_comp
void spair_set_insert(spair *p)
gbelem * gbelem_ring_make(gbvector *f)
long max_reduction_count
int ar_j
int stats_nretired
MonomialTableZZ * lookupZZ
enum gbA::gbA_state state
ReducedGB * minimal_gb
spair * new_gen(int i, gbvector *f, ring_elem denom)
int n_fraction_vars
bool use_hilb
@ STATE_NEWDEGREE
int n_gb
int complete_thru_this_degree
int stats_nreductions
int np_i
int hilb_n_in_degree
int ar_i
int stats_npairs
M2_arrayint gb_weights
int n_saved_hilb
const GBWeight * weightInfo_
const FreeModule * _F
const FreeModule * _Fsyz
stash * lcm_stash
bool _collect_syz
bool hilb_new_elems
int n_syz
bool over_ZZ() const
int stats_ntail
int npairs
RingElement * hf_diff
int this_degree
stash * spair_stash
SPairSet * S
bool is_local_gb
int n_rows_per_syz
int divisor_previous
bool minimal_gb_valid
bool _is_ideal
const MonomialTableZZ * ringtableZZ
size_t exp_size
int stats_ngcd1
int first_in_degree
const RingElement * hf_orig
@ COMP_NOT_STARTED
Definition computation.h:58
void gb(IntermediateBasis &F, int n)
int p
const int ERROR
Definition m2-mem.cpp:55
#define EXPONENT_BYTE_SIZE(nvars)
Definition monoid.hpp:63

References _coeff_type, _collect_syz, _F, _Fsyz, _is_ideal, _nvars, _strategy, ar_i, ar_j, Ring::cast_to_PolynomialRing(), PolynomialRing::coefficient_type(), Matrix::cols(), COMP_NOT_STARTED, complete_thru_this_degree, ReducedGB::create(), divisor_previous, divisor_previous_comp, ERROR, exp_size, EXPONENT_BYTE_SIZE, first_gb_element, first_in_degree, gb(), gb_weights, gbelem_ring_make(), gbelem_stash, PolynomialRing::get_gb_ring(), Matrix::get_ring(), PolynomialRing::getMonoid(), hf_diff, hf_orig, hilb_n_in_degree, hilb_new_elems, is_local_gb, lcm_stash, lookup, lookupZZ, MonomialTable::make(), MonomialTableZZ::make(), Matrix, max_reduction_count, minimal_gb, minimal_gb_valid, Matrix::n_cols(), n_fraction_vars, PolynomialRing::n_fraction_vars(), n_gb, n_gens_left, n_pairs_computed, n_rows_per_syz, n_saved_hilb, n_subring, n_syz, new_gen(), np_i, npairs, originalR, over_ZZ(), p, R, ringtable, ringtableZZ, Matrix::rows(), S, Computation::set_status(), spair_set_insert(), spair_stash, state, STATE_NEWDEGREE, stats_ngb, stats_ngcd1, stats_npairs, stats_nreductions, stats_nretired, stats_ntail, FreeModule::sub_space(), this_degree, use_hilb, and weightInfo_.