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

◆ vec_top_coefficient()

vec PolyRing::vec_top_coefficient ( const vec v,
int & var,
int & exp ) const
virtual

Implements PolynomialRing.

Definition at line 2374 of file poly.cpp.

2382{
2383 x = n_vars();
2384 e = 0;
2385 if (v == nullptr)
2386 {
2387 return nullptr;
2388 }
2389
2391 for (vec t = v; t != nullptr; t = t->next)
2392 for (Nterm& f : t->coeff)
2393 {
2394 M_->to_expvector(f.monom, exp);
2395 for (int i = 0; i < x; i++)
2396 {
2397 if (exp[i] > 0)
2398 {
2399 x = i;
2400 e = exp[i];
2401 break;
2402 }
2403 }
2404 if (x < n_vars() && exp[x] > e) e = exp[x];
2405 }
2406
2407 // Now we have the variable, and its exponent.
2408 freemem(exp);
2409 if (x == n_vars()) return v;
2410 return vec_coefficient_of_var(v, x, e);
2411}
exponents::Exponents exponents_t
vec vec_coefficient_of_var(vec v, int var, int exp) const
Definition poly.cpp:2345
const Monoid * M_
Definition polyring.hpp:124
int n_vars() const
Definition polyring.hpp:196
void freemem(void *s)
Definition m2-mem.cpp:103
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
volatile int x
int monom[1]
Definition ringelem.hpp:160

References Nterm::coeff, freemem(), PolynomialRing::M_, Nterm::monom, PolynomialRing::n_vars(), newarray_atomic, vec_coefficient_of_var(), and x.