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

◆ coeff_of()

int hilb_comp::coeff_of ( const RingElement * h,
int deg )
static

Definition at line 704 of file hilb.cpp.

705{
706 // This is a bit of a kludge of a routine. The idea is to loop through
707 // all the terms of the polynomial h, expand out the exponent, and to add
708 // up the small integer values of the coefficients of those that have
709 // exp[0]=deg.
710 const PolynomialRing *P = h->get_ring()->cast_to_PolynomialRing();
711
713 int result = 0;
714 for (Nterm& f : h->get_value())
715 {
716 P->getMonoid()->to_expvector(f.monom, exp);
717 if (exp[0] < deg)
718 {
719 ERROR("incorrect Hilbert function given");
720 fprintf(
721 stderr,
722 "internal error: incorrect Hilbert function given, aborting\n");
723 fprintf(
724 stderr,
725 "exp[0]: %d deg: %d\n", exp[0], deg);
726 abort();
727 }
728 else if (exp[0] == deg)
729 {
730 std::pair<bool, long> res =
732 assert(res.first &&
733 std::abs(res.second) < std::numeric_limits<int>::max());
734 int n = static_cast<int>(res.second);
735 result += n;
736 }
737 }
738 freemem(exp);
739 return result;
740}
exponents::Exponents exponents_t
void to_expvector(const_monomial m, exponents_t result_exp) const
Definition monoid.cpp:747
const Ring * getCoefficientRing() const
Definition polyring.hpp:200
virtual const Monoid * getMonoid() const
Definition polyring.hpp:282
int n_vars() const
Definition polyring.hpp:196
virtual std::pair< bool, long > coerceToLongInteger(ring_elem a) const
Definition ring.cpp:236
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
ring_elem get_value() const
Definition relem.hpp:79
const Ring * get_ring() const
Definition relem.hpp:81
void freemem(void *s)
Definition m2-mem.cpp:103
const int ERROR
Definition m2-mem.cpp:55
VALGRIND_MAKE_MEM_DEFINED & result(result)
const mpreal exp(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2298
#define newarray_atomic(T, len)
Definition newdelete.hpp:91

References Ring::cast_to_PolynomialRing(), Ring::coerceToLongInteger(), ERROR, freemem(), RingElement::get_ring(), RingElement::get_value(), PolynomialRing::getCoefficientRing(), PolynomialRing::getMonoid(), PolynomialRing::n_vars(), newarray_atomic, result(), and Monoid::to_expvector().

Referenced by gb2_comp::calc_gb(), gbA::do_computation(), HilbertController::setDegree(), and GB_comp::start_computation().