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

◆ new_pairs()

void res_comp::new_pairs ( res_pair * p)
private

Definition at line 606 of file res-a1.cpp.

613{
614 gc_vector<Bag*> elems;
615 gc_vector<int> vp; // This is 'p'.
616 gc_vector<int> thisvp;
617
619
620 if (M2_gbTrace >= 10)
621 {
622 buffer o;
623 o << "Computing pairs with first = " << p->me << newline;
624 emit(o.str());
625 }
626 M->divide(p->base_monom, p->first->base_monom, PAIRS_mon);
627 M->to_varpower(PAIRS_mon, vp);
628
629 // First add in syzygies arising from exterior variables
630 // At the moment, there are none of this sort.
631
632 if (P->is_skew_commutative())
633 {
634 exponents_t exp = newarray_atomic(int, M->n_vars());
635 varpower::to_expvector(M->n_vars(), vp.data(), exp);
636
637 int nskew = P->n_skew_commutative_vars();
638 for (int v = 0; v < nskew; v++)
639 {
640 int w = P->skew_variable(v);
641 if (exp[w] > 0)
642 {
643 thisvp.resize(0);
644 varpower::var(w, 1, thisvp);
645 Bag *b = new Bag(static_cast<void *>(nullptr), thisvp);
646 elems.push_back(b);
647 }
648 }
649 freemem(exp);
650 }
651
652 // Second, add in syzygies arising from the base ring, if any
653 // The baggage of each of these is NULL
654 if (P->is_quotient_ring())
655 {
656 const MonomialIdeal *Rideal = P->get_quotient_monomials();
657 for (Bag& a : *Rideal)
658 {
659 // Compute (P->quotient_ideal->monom : p->monom)
660 // and place this into a varpower and Bag, placing
661 // that into 'elems'
662 thisvp.resize(0);
663 varpower::quotient(a.monom().data(), vp.data(), thisvp);
664 if (varpower::is_equal(a.monom().data(), thisvp.data()))
665 continue;
666 Bag *b = new Bag(static_cast<void *>(nullptr), thisvp);
667 elems.push_back(b);
668 }
669 }
670 // Third, add in syzygies arising from previous elements of this same level
671 // The baggage of each of these is their corresponding res_pair
672
673 MonomialIdeal *mi_orig = p->first->mi;
674 for (Bag& a : *mi_orig)
675 {
676 Bag *b = new Bag(a.basis_ptr());
677 varpower::quotient(a.monom().data(), vp.data(), b->monom());
678 elems.push_back(b);
679 }
680
681 // Make this monomial ideal, and then run through each minimal generator
682 // and insert into the proper degree. (Notice that sorting does not
683 // need to be done yet: only once that degree is about to begin.
684
685 mi_orig->insert_minimal(new Bag(p, vp));
686
687 VECTOR(Bag *) rejects;
688 MonomialIdeal *mi = new MonomialIdeal(P, elems, rejects, mi_stash);
689 for (auto& b : rejects)
690 delete b;
691
692 if (M2_gbTrace >= 11) mi->debug_out(1);
693
694 for (Bag& a : *mi)
695 {
696 res_pair *second = reinterpret_cast<res_pair *>(a.basis_ptr());
697 res_pair *q = new_res_pair(SYZ_S_PAIR, p, second);
698 // That set most fields except base_monom:
699 M->from_varpower(a.monom().data(), q->base_monom);
700 M->mult(q->base_monom, p->base_monom, q->base_monom);
702 }
703 delete mi;
704}
exponents::Exponents exponents_t
static void quotient(ConstExponents a, ConstExponents b, Vector &result)
static bool is_equal(ConstExponents a, ConstExponents b)
static void to_expvector(int n, ConstExponents a, exponents::Exponents result)
static void var(Exponent v, Exponent e, Vector &result)
void debug_out(int disp=1) const
Definition monideal.cpp:508
char * str()
Definition buffer.hpp:72
gc_vector< int > & monom()
Definition int-bag.hpp:60
const Monoid * M
Definition res-a1.hpp:80
int n_level
Definition res-a1.hpp:88
stash * mi_stash
Definition res-a1.hpp:85
res_pair * new_res_pair()
Definition res-a1.cpp:210
const PolynomialRing * P
Definition res-a1.hpp:78
void insert_res_pair(int level, res_pair *p)
Definition res-a1.cpp:288
size_t monom_size
Definition res-a1.hpp:115
int * base_monom
#define monomial
Definition gb-toric.cpp:11
int p
int_bag Bag
Definition int-bag.hpp:70
void freemem(void *s)
Definition m2-mem.cpp:103
char newline[]
Definition m2-types.cpp:49
int M2_gbTrace
Definition m2-types.cpp:52
#define ALLOCATE_MONOMIAL(byte_len)
Definition monoid.hpp:65
const mpreal exp(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2298
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
#define VECTOR(T)
Definition newdelete.hpp:78
#define newarray_atomic(T, len)
Definition newdelete.hpp:91
@ SYZ_S_PAIR
void emit(const char *s)
Definition text-io.cpp:41

References ALLOCATE_MONOMIAL, res_pair::base_monom, MonomialIdeal::debug_out(), emit(), freemem(), MonomialIdeal::insert_minimal(), insert_res_pair(), ExponentList< int, true >::is_equal(), M, M2_gbTrace, mi_stash, int_bag::monom(), monom_size, monomial, n_level, new_res_pair(), newarray_atomic, newline, P, p, ExponentList< int, true >::quotient(), buffer::str(), SYZ_S_PAIR, ExponentList< int, true >::to_expvector(), ExponentList< int, true >::var(), and VECTOR.

Referenced by pairs().