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

◆ get_coeff()

ring_elem PolyRing::get_coeff ( const Ring * coeffR,
const ring_elem f,
const_varpower vp ) const
virtual

Definition at line 1989 of file poly.cpp.

1992{
1993 int nvars0 = check_coeff_ring(coeffR, this);
1994 if (nvars0 < 0) return from_long(0);
1995
1996 exponents_t exp = newarray_atomic(int, nvars0);
1997 exponents_t exp2 = newarray_atomic(int, n_vars()); // FLAT number of variables
1998 varpower::to_expvector(nvars0, vp, exp);
1999
2000 // Now loop thru f until exponents match up.
2001 const Nterm *t = f;
2002 for (; t != nullptr; t = t->next)
2003 {
2004 M_->to_expvector(t->monom, exp2);
2005 if (EQ == exponents::lex_compare(nvars0, exp, exp2)) break;
2006 }
2007
2008 ring_elem result = get_logical_coeff(coeffR, t);
2009 freemem(exp2);
2010 freemem(exp);
2011 return result;
2012}
exponents::Exponents exponents_t
static void to_expvector(int n, ConstExponents a, exponents::Exponents result)
static int lex_compare(int nvars, ConstExponents a, ConstExponents b)
virtual ring_elem from_long(long n) const
Definition poly.cpp:169
ring_elem get_logical_coeff(const Ring *coeffR, const Nterm *&f) const
Definition poly.cpp:1701
const Monoid * M_
Definition polyring.hpp:124
int n_vars() const
Definition polyring.hpp:196
void freemem(void *s)
Definition m2-mem.cpp:103
VALGRIND_MAKE_MEM_DEFINED & result(result)
const mpreal exp2(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2299
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
int check_coeff_ring(const Ring *coeffR, const PolyRing *P)
Definition poly.cpp:359
Nterm * next
Definition ringelem.hpp:157
int monom[1]
Definition ringelem.hpp:160
const int EQ
Definition style.hpp:40

References check_coeff_ring(), EQ, freemem(), from_long(), get_logical_coeff(), ExponentVector< int, true >::lex_compare(), PolynomialRing::M_, Nterm::monom, PolynomialRing::n_vars(), newarray_atomic, Nterm::next, result(), Ring::Ring(), and ExponentList< int, true >::to_expvector().