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

◆ iquotient_and_sum()

void iquotient_and_sum ( MonomialIdeal & I,
const_varpower m,
MonomialIdeal *& quot,
MonomialIdeal *& sum,
stash * mi_stash )
static

Definition at line 267 of file hilb.cpp.

272{
273 gc_vector<Bag*> elems;
274 sum = new MonomialIdeal(I.get_ring(), mi_stash);
275 quot = new MonomialIdeal(I.get_ring(), mi_stash);
276 Bag *bmin = new Bag();
277 varpower::copy(m, bmin->monom());
278 sum->insert_minimal(bmin);
279 for (Bag& a : I)
280 {
281 Bag *b = new Bag();
282 varpower::quotient(a.monom().data(), m, b->monom());
283 if (varpower::divides(m, a.monom().data()))
284 quot->insert_minimal(b);
285 else
286 {
287 sum->insert_minimal(new Bag(0, a.monom()));
288 elems.push_back(b);
289 }
290 }
291
292 // Now we sort items in 'elems' so that we can insert as min gens into 'quot'
293 std::vector<std::pair<int, int>> degs_and_indices;
294 int count = 0;
295 for (auto& b : elems)
296 {
297 int deg = varpower::simple_degree(b->monom().data());
298 degs_and_indices.push_back(std::make_pair(deg, count));
299 ++count;
300 }
301 std::stable_sort(degs_and_indices.begin(), degs_and_indices.end());
302
303 for (auto p : degs_and_indices)
304 {
305 Bag* b = elems[p.second];
306 Bag* b1; // not used here...
307 if (quot->search(b->monom().data(), b1))
308 delete b;
309 else
310 quot->insert_minimal(b);
311 }
312}
static void quotient(ConstExponents a, ConstExponents b, Vector &result)
static Exponent simple_degree(ConstExponents m)
static void copy(ConstExponents vp, Vector &result)
static bool divides(ConstExponents a, ConstExponents b)
int search(const_varpower m, Bag *&b) const
Definition monideal.cpp:278
void insert_minimal(Bag *b)
Definition monideal.hpp:333
const PolynomialRing * get_ring() const
Definition monideal.hpp:190
Engine-side monomial ideal: a decision tree of Nmi_nodes storing the (typically minimal) generators b...
Definition monideal.hpp:136
gc_vector< int > & monom()
Definition int-bag.hpp:60
int p
int_bag Bag
Definition int-bag.hpp:70
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
Definition mpreal.h:2600
typename std::vector< T, gc_allocator< T > > gc_vector
a version of the STL vector, which allocates its backing memory with gc.
Definition newdelete.hpp:76

References ExponentList< int, true >::copy(), ExponentList< int, true >::divides(), MonomialIdeal::get_ring(), MonomialIdeal::insert_minimal(), int_bag::monom(), p, ExponentList< int, true >::quotient(), MonomialIdeal::search(), and ExponentList< int, true >::simple_degree().

Referenced by hilb_comp::recurse().