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

◆ gb_insert()

void GBinhom_comp::gb_insert ( gbvector * f,
gbvector * fsyz,
int minlevel )
private

Definition at line 618 of file gb-sugarless.cpp.

619{
620 monomial f_m = M->make_one();
621 minlevel = (minlevel == 0 ? MINGB_MASK : MINGEN_MASK | MINGB_MASK);
622 gb_elem *p = new gb_elem(f, fsyz, minlevel);
623 p->me = last_gb_num++;
624 p->lead_exp = newarray_atomic(int, M->n_vars());
625
626 GR->gbvector_get_lead_monomial(F, p->f, f_m);
627 GR->gbvector_remove_content(p->f, p->fsyz);
628
629 M->to_expvector(f_m, p->lead_exp);
630 if (M->in_subring(1, f_m)) n_subring++;
631
632 // Next determine the new s pairs. This also deletes unneeded pairs
633 find_pairs(p);
634
635 // Insert into the Groebner basis
636 minimal_gb_valid = false;
637 gb_elem *q = gbLarge;
638 gb_elem *prevmin = gb;
639 for (;;)
640 {
641 if (q->next == nullptr || compare(p, q->next) == LT)
642 {
643 p->next = q->next;
644 q->next = p;
645 n_gb++;
646 // Now place into the minimal list as well
647 p->next_min = prevmin->next_min;
648 prevmin->next_min = p;
649 break;
650 }
651 else if (q->next->is_min & MINGB_MASK)
652 prevmin = q->next;
653 q = q->next;
654 }
655
656 M->remove(f_m);
657
658 // At this point 'p' has been inserted. Now we need to remove the
659 // non-minimal elements.
660 q = p;
661 while (q->next_min != nullptr)
662 // MES: this loop would be a good place to put in auto-reduction?
663 if (p->f->comp == q->next_min->f->comp &&
664 M->divides(p->f->monom, q->next_min->f->monom))
665 {
666 gb_elem *tmp = q->next_min;
667 q->next_min = tmp->next_min;
668 tmp->next_min = nullptr;
669 tmp->is_min ^= MINGB_MASK; // I.e. not in the minimal GB
670 n_gb--;
671 }
672 else
673 q = q->next_min;
674}
void find_pairs(gb_elem *p)
int compare(const gb_elem *p, const gb_elem *q) const
gb_elem * gbLarge
const FreeModule * F
const Monoid * M
static const int MINGB_MASK
static const int MINGEN_MASK
#define monomial
Definition gb-toric.cpp:11
int p
#define newarray_atomic(T, len)
Definition newdelete.hpp:91
int is_min
Definition spair.hpp:61
gb_elem * next
Definition spair.hpp:55
gbvector * f
Definition spair.hpp:58
gb_elem * next_min
Definition spair.hpp:56
int monom[1]
Definition gbring.hpp:83
int comp
Definition gbring.hpp:82
const int LT
Definition style.hpp:39

References gbvector::comp, compare(), F, gb_elem::f, find_pairs(), gb, gbLarge, GR, gb_elem::is_min, last_gb_num, LT, M, MINGB_MASK, MINGEN_MASK, minimal_gb_valid, gbvector::monom, monomial, n_gb, n_subring, newarray_atomic, gb_elem::next, gb_elem::next_min, and p.

Referenced by s_pair_step().