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

◆ insert()

void MonomialTableZZ::insert ( mpz_srcptr coeff,
exponents_t exp,
int comp,
int id )

Definition at line 400 of file montableZZ.cpp.

401{
402 /* Insert 'exp' into the monomial table. These are kept sorted in ascending
403 order
404 in some order (lex order?). No element is ever removed.
405 */
406
407 if (comp >= INTSIZE(_head))
408 {
409 for (int i = INTSIZE(_head); i <= comp; i++)
410 _head.push_back(make_list_head());
411 }
412
413 mon_term *head = _head[comp];
414 mon_term *t;
415
416 /* Make a new mon_term including exp */
417 mon_term *newterm = new mon_term;
418 newterm->_lead = exp;
419 newterm->_mask = monomial_mask(_nvars, exp);
420 newterm->_val = id;
421 newterm->_coeff = coeff;
422 _count++;
423
424 /* Find where to put it */
425 for (t = head; t->_next != head; t = t->_next)
426 {
427 if (exponents_greater(_nvars, newterm->_lead, t->_next->_lead))
428 {
429 /* Time to insert newterm, right between t, t->next */
430 break;
431 }
432 }
433
434 /* The actual insertion */
435 newterm->_next = t->_next;
436 newterm->_prev = t;
437 t->_next->_prev = newterm;
438 t->_next = newterm;
439}
static mon_term * make_list_head()
static unsigned long monomial_mask(int nvars, exponents_t exp)
static bool exponents_greater(int nvars, exponents_t a, exponents_t b)
const mpreal exp(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2298
MonomialTable::mon_term plus an _coeff slot pointing at the entry's leading ZZ coefficient (or nullpt...
#define INTSIZE(a)
Definition style.hpp:37

References MonomialTableZZ::mon_term::_coeff, _count, MonomialTableZZ::mon_term::_lead, MonomialTableZZ::mon_term::_mask, MonomialTableZZ::mon_term::_next, _nvars, MonomialTableZZ::mon_term::_prev, MonomialTableZZ::mon_term::_val, exponents_greater(), INTSIZE, make_list_head(), and monomial_mask().