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

◆ new_pairs()

void res2_comp::new_pairs ( res2_pair * p)

Definition at line 951 of file res-a0.cpp.

954{
955 gc_vector<Bag*> elems;
956 gc_vector<int> vp; // This is 'p'.
957 gc_vector<int> thisvp;
958
960
961 if (M2_gbTrace >= 10)
962 {
963 buffer o;
964 o << "Computing pairs with first = " << p->pair_num << newline;
965 emit(o.str());
966 }
967 M->divide(p->syz->monom, p->syz->comp->syz->monom, PAIRS_mon);
968 M->to_varpower(PAIRS_mon, vp);
969
970 // First add in syzygies arising from exterior variables
971 // At the moment, there are none of this sort.
972
973 if (P->is_skew_commutative())
974 {
975 exponents_t exp = newarray_atomic(int, M->n_vars());
976 varpower::to_expvector(M->n_vars(), vp.data(), exp);
977
978 int nskew = P->n_skew_commutative_vars();
979 for (int v = 0; v < nskew; v++)
980 {
981 int w = P->skew_variable(v);
982 if (exp[w] > 0)
983 {
984 thisvp.resize(0);
985 varpower::var(w, 1, thisvp);
986 Bag *b = new Bag(static_cast<void *>(nullptr), thisvp);
987 elems.push_back(b);
988 }
989 }
990 freemem(exp);
991 }
992
993 // Second, add in syzygies arising from the base ring, if any
994 // The baggage of each of these is NULL
995 if (P->is_quotient_ring())
996 {
997 const MonomialIdeal *Rideal = P->get_quotient_monomials();
998 for (Bag& a : *Rideal)
999 {
1000 // Compute (P->quotient_ideal->monom : p->monom)
1001 // and place this into a varpower and Bag, placing
1002 // that into 'elems'
1003 thisvp.resize(0);
1004 varpower::quotient(a.monom().data(), vp.data(), thisvp);
1005 if (varpower::is_equal(a.monom().data(), thisvp.data()))
1006 continue;
1007 Bag *b = new Bag(static_cast<void *>(nullptr), thisvp);
1008 elems.push_back(b);
1009 }
1010 }
1011
1012 // Third, add in syzygies arising from previous elements of this same level
1013 // The baggage of each of these is their corresponding res2_pair
1014
1015 MonomialIdeal *mi_orig = p->syz->comp->mi;
1016 for (Bag& a : *mi_orig)
1017 {
1018 Bag *b = new Bag(a.basis_ptr());
1019 varpower::quotient(a.monom().data(), vp.data(), b->monom());
1020 elems.push_back(b);
1021 }
1022
1023 // Make this monomial ideal, and then run through each minimal generator
1024 // and insert into the proper degree. (Notice that sorting does not
1025 // need to be done yet: only once that degree is about to begin.
1026
1027 mi_orig->insert_minimal(new Bag(p, vp));
1028
1029 MonomialIdeal mi(P, elems);
1030
1031 if (M2_gbTrace >= 11) mi.debug_out(1);
1032
1033 monomial m = M->make_one();
1034 for (Bag& a : mi)
1035 {
1036 res2_pair *second = reinterpret_cast<res2_pair *>(a.basis_ptr());
1037 M->from_varpower(a.monom().data(), m);
1038 M->mult(m, p->syz->monom, m);
1039
1040 res2_pair *q = new_res2_pair(p, second, m);
1041 insert_pair(q);
1042 }
1043}
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)
char * str()
Definition buffer.hpp:72
gc_vector< int > & monom()
Definition int-bag.hpp:60
res2_pair * new_res2_pair(int i)
Definition res-a0.cpp:646
size_t monom_size
Definition res-a0.hpp:193
const Monoid * M
Definition res-a0.hpp:124
const PolynomialRing * P
Definition res-a0.hpp:122
void insert_pair(res2_pair *p)
Definition res-a0.cpp:663
#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 newarray_atomic(T, len)
Definition newdelete.hpp:91
void emit(const char *s)
Definition text-io.cpp:41

References ALLOCATE_MONOMIAL, MonomialIdeal::debug_out(), emit(), freemem(), MonomialIdeal::insert_minimal(), insert_pair(), ExponentList< int, true >::is_equal(), M, M2_gbTrace, int_bag::monom(), monom_size, monomial, new_res2_pair(), newarray_atomic, newline, P, p, ExponentList< int, true >::quotient(), buffer::str(), ExponentList< int, true >::to_expvector(), and ExponentList< int, true >::var().

Referenced by skeleton().