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

◆ intersect() [1/2]

MonomialIdeal * MonomialIdeal::intersect ( const MonomialIdeal & J) const

Definition at line 668 of file monideal.cpp.

669{
670 // The idea: take the elements of 'this'
671 // for each: if the element is in J, then keep it directly.
672 // otherwie compute the lcm's.
673 VECTOR(Bag*) new_elems;
674 for (Bag& a : *this)
675 {
676 Bag *c;
677 if (J.search(a.monom().data(), c))
678 {
679 new_elems.push_back(new Bag(a));
680 }
681 else
682 for (Bag& b : J)
683 {
684 Bag *new_elem = new Bag(a.basis_elem());
685 varpower::lcm(a.monom().data(),
686 b.monom().data(),
687 new_elem->monom());
688 new_elems.push_back(new_elem);
689 }
690 }
691 MonomialIdeal *result = new MonomialIdeal(get_ring(), new_elems);
692 GC_reachable_here(&J);
693 return result;
694}
static void lcm(ConstExponents a, ConstExponents b, Vector &result)
int search(const_varpower m, Bag *&b) const
Definition monideal.cpp:278
MonomialIdeal(const PolynomialRing *RR, stash *mi_stash=nullptr)
Definition monideal.cpp:91
const PolynomialRing * get_ring() const
Definition monideal.hpp:190
int basis_elem() const
Definition int-bag.hpp:66
gc_vector< int > & monom()
Definition int-bag.hpp:60
int_bag Bag
Definition int-bag.hpp:70
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define VECTOR(T)
Definition newdelete.hpp:78

References int_bag::basis_elem(), get_ring(), ExponentList< int, true >::lcm(), int_bag::monom(), MonomialIdeal(), result(), search(), and VECTOR.