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

◆ skeleton_pairs()

void res_comp::skeleton_pairs ( res_pair *& result,
res_pair * p )

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

1499{
1500 gc_vector<Bag*> elems;
1501 gc_vector<int> vp; // This is 'p'.
1502 gc_vector<int> thisvp;
1503
1505
1506 if (M2_gbTrace >= 10)
1507 {
1508 buffer o;
1509 o << "Computing pairs with first = " << p->me << newline;
1510 emit(o.str());
1511 }
1512 M->divide(p->base_monom, p->first->base_monom, PAIRS_mon);
1513 M->to_varpower(PAIRS_mon, vp);
1514
1515 // First add in syzygies arising from exterior variables
1516 // At the moment, there are none of this sort.
1517
1518 if (P->is_skew_commutative())
1519 {
1520
1521 exponents_t exp = newarray_atomic(int, M->n_vars());
1522 varpower::to_expvector(M->n_vars(), vp.data(), exp);
1523
1524 int nskew = P->n_skew_commutative_vars();
1525 for (int v = 0; v < nskew; v++)
1526 {
1527 int w = P->skew_variable(v);
1528 if (exp[w] > 0)
1529 {
1530 thisvp.resize(0);
1531 varpower::var(w, 1, thisvp);
1532 Bag *b = new Bag(static_cast<void *>(nullptr), thisvp);
1533 elems.push_back(b);
1534 }
1535 }
1536 freemem(exp);
1537 }
1538
1539 // Second, add in syzygies arising from the base ring, if any
1540 // The baggage of each of these is NULL
1541 if (P->is_quotient_ring())
1542 {
1543 const MonomialIdeal *Rideal = P->get_quotient_monomials();
1544 for (Bag& a : *Rideal)
1545 {
1546 // Compute (P->quotient_ideal->monom : p->monom)
1547 // and place this into a varpower and Bag, placing
1548 // that into 'elems'
1549 thisvp.resize(0);
1550 varpower::quotient(a.monom().data(), vp.data(), thisvp);
1551 if (varpower::is_equal(a.monom().data(), thisvp.data()))
1552 continue;
1553 Bag *b = new Bag(static_cast<void *>(nullptr), thisvp);
1554 elems.push_back(b);
1555 }
1556 }
1557
1558 // Third, add in syzygies arising from previous elements of this same level
1559 // The baggage of each of these is their corresponding res_pair
1560
1561 MonomialIdeal *mi_orig = p->first->mi;
1562 for (Bag& a : *mi_orig)
1563 {
1564 Bag *b = new Bag(a.basis_ptr());
1565 varpower::quotient(a.monom().data(), vp.data(), b->monom());
1566 elems.push_back(b);
1567 }
1568
1569 // Make this monomial ideal, and then run through each minimal generator
1570 // and insert into the proper degree. (Notice that sorting does not
1571 // need to be done yet: only once that degree is about to begin.
1572
1573 mi_orig->insert_minimal(new Bag(p, vp));
1574
1575 MonomialIdeal *mi = new MonomialIdeal(P, elems);
1576
1577 if (M2_gbTrace >= 11) mi->debug_out(1);
1578
1579 for (Bag& a : *mi)
1580 {
1581 res_pair *second = reinterpret_cast<res_pair *>(a.basis_ptr());
1582 res_pair *q = new_res_pair(SYZ_S_PAIR, p, second);
1583 // That set most fields except base_monom:
1584 M->from_varpower(a.monom().data(), q->base_monom);
1585 M->mult(q->base_monom, p->base_monom, q->base_monom);
1586 result->next = q;
1587 result = q;
1588 }
1589
1590 delete mi;
1591}
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
res_pair * new_res_pair()
Definition res-a1.cpp:210
const PolynomialRing * P
Definition res-a1.hpp:78
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
VALGRIND_MAKE_MEM_DEFINED & result(result)
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
@ 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(), ExponentList< int, true >::is_equal(), M, M2_gbTrace, int_bag::monom(), monom_size, monomial, new_res_pair(), newarray_atomic, newline, P, p, ExponentList< int, true >::quotient(), result(), buffer::str(), SYZ_S_PAIR, ExponentList< int, true >::to_expvector(), and ExponentList< int, true >::var().

Referenced by skeleton().