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

◆ insert_gb()

void gbA::insert_gb ( POLY f,
gbelem_type minlevel )
private

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

2142{
2143 /* Reduce this element as far as possible. This either removes content,
2144 makes it monic, or at least negates it so the lead coeff is positive. */
2145 ring_elem junk;
2146
2147 // DEBUG BLOCK int fwt;
2148 // int fdeg = weightInfo_->gbvector_weight(f.f, fwt);
2149 // fprintf(stderr, "inserting GB element %d, thisdeg %d deg %d gap %d\n",
2150 // gb.size(),
2151 // this_degree,
2152 // fdeg,
2153 // fdeg-fwt);
2154
2155 if (is_local_gb)
2156 R->gbvector_remove_content(f.f, f.fsyz, false, junk);
2157 else
2158 remainder(f, this_degree, false, junk);
2159
2160 // fdeg = weightInfo_->gbvector_weight(f.f, fwt);
2161 // fprintf(stderr, " after remainder deg %d gap %d\n",
2162 // fdeg,
2163 // fdeg-fwt);
2164
2165 stats_ngb++;
2166
2167 // Complete hack for getting bug fix to get test/isSubset.m2 to work again for
2168 // 1.3:
2169 // over ZZ, always make gb elements non reducers...
2170 if (over_ZZ()) minlevel |= ELEM_MINGB;
2171
2172 gbelem *g = gbelem_make(f.f, f.fsyz, minlevel, this_degree);
2173 minimal_gb_valid = false;
2174 int me = INTSIZE(gb);
2175 gb.push_back(g);
2176 forwardingZZ.push_back(-1);
2177 n_gb++;
2178 int x = g->g.f->comp;
2179
2180 // In a encoded Schreyer order, the following line might miss subring
2181 // elements.
2182 // But it at least won't be incorrect...
2183 if (R->get_flattened_monoid()->in_subring(1, g->g.f->monom)) n_subring++;
2184
2185 if (over_ZZ())
2186 lookupZZ->insert(g->g.f->coeff.get_mpz(), g->lead, x, me);
2187 else
2188 lookup->insert(g->lead, x, me);
2189
2190 if (M2_gbTrace == 15)
2191 {
2192 buffer o;
2193 o << " new ";
2194 gbelem_text_out(o, INTSIZE(gb) - 1);
2195 emit_line(o.str());
2196 }
2197 else if (M2_gbTrace >= 5)
2198 {
2199 const int N = 100;
2200 char s[N];
2201 buffer o;
2202 snprintf(s, N, "new-inserting element %d (minimal %d): ", me, minlevel);
2203 o << s;
2204 R->gbvector_text_out(o, _F, g->g.f);
2205 emit_line(o.str());
2206 o.reset();
2207 o << " syzygy : ";
2208 R->gbvector_text_out(o, _Fsyz, g->g.fsyz);
2209 emit_line(o.str());
2210 }
2211
2212 if (!is_local_gb) auto_reduce_by(me);
2213
2214 if (use_hilb)
2215 {
2216 hilb_new_elems = true;
2217 if (--hilb_n_in_degree == 0) flush_pairs();
2218 }
2219 else
2220 {
2221#ifdef DEVELOPMENT
2222#warning "todo: codimension stop condition"
2223#endif
2224 // codim test is set. Compute the codimension now.
2225 }
2226
2227 if (M2_gbTrace >= 10)
2228 {
2229 // lookupZZ->showmontable();
2230 // show();
2231 }
2232}
char * str()
Definition buffer.hpp:72
void reset()
Definition buffer.hpp:69
MonomialTable * lookup
GBRing * R
void flush_pairs()
int stats_ngb
int n_subring
gbelem * gbelem_make(gbvector *f, gbvector *fsyz, gbelem_type minlevel, int deg)
MonomialTableZZ * lookupZZ
void remainder(POLY &f, int degf, bool use_denom, ring_elem &denom)
bool use_hilb
int n_gb
void gbelem_text_out(buffer &o, int i, int nterms=3) const
void auto_reduce_by(int id)
int hilb_n_in_degree
const FreeModule * _F
const FreeModule * _Fsyz
bool hilb_new_elems
bool over_ZZ() const
int this_degree
bool is_local_gb
bool minimal_gb_valid
void gb(IntermediateBasis &F, int n)
const int ELEM_MINGB
void size_t s
Definition m2-mem.cpp:271
int M2_gbTrace
Definition m2-types.cpp:52
volatile int x
gbvector * fsyz
Definition gbring.hpp:99
gbvector * f
Definition gbring.hpp:98
GBF4Polynomial f
Definition f4-types.hpp:139
#define INTSIZE(a)
Definition style.hpp:37
void emit_line(const char *s)
Definition text-io.cpp:47

References _F, _Fsyz, auto_reduce_by(), gbvector::coeff, gbvector::comp, ELEM_MINGB, emit_line(), POLY::f, flush_pairs(), POLY::fsyz, gbA::gbelem::g, gb(), gbelem_make(), gbelem_text_out(), ring_elem::get_mpz(), hilb_n_in_degree, hilb_new_elems, INTSIZE, is_local_gb, gbA::gbelem::lead, lookup, lookupZZ, M2_gbTrace, minimal_gb_valid, gbvector::monom, n_gb, n_subring, over_ZZ(), POLY, R, remainder(), buffer::reset(), s, stats_ngb, buffer::str(), this_degree, use_hilb, and x.

Referenced by process_spair(), reduce_kk(), and reduce_ZZ().