36 return Q->n_terms(
val);
51 ERROR(
"ring division: attempt to divide by zero");
61 ERROR(
"ring addition requires both elements to have the same base ring");
65 if (
error())
return nullptr;
74 "ring subtraction requires both elements to have the same base ring");
78 if (
error())
return nullptr;
87 "ring multiplication requires both elements to have the same base "
92 if (
error())
return nullptr;
109 ERROR(
"ring division requires both elements to have the same base ring");
114 ERROR(
"ring division: attempt to divide by zero");
118 if (
error())
return nullptr;
126 if (
error())
return nullptr;
133 if (
error())
return nullptr;
144 R->elem_text_out(o,
val);
161 ERROR(
"expected polynomial ring");
181 ERROR(
"expected polynomial ring");
191 ERROR(
"expected polynomial ring");
201 ERROR(
"the zero element has no lead monomial");
218 ERROR(
"not implemented yet");
221 ERROR(
"expected polynomial ring");
234 ERROR(
"zero element has no degree");
239 ERROR(
"expected polynomial ring");
250 ERROR(
"expected polynomial ring");
253 if (v < 0 || v >= P->
n_vars())
255 ERROR(
"homogenization: improper ring variable");
258 if (wts.size() == 0 || wts.size() !=
static_cast<unsigned int>(P->
n_vars()))
260 ERROR(
"homogenization: improper weight function");
265 ERROR(
"homogenization: variable weight is zero");
270 if (
error())
return nullptr;
276 const std::vector<int> &wts)
const
281 ERROR(
"expected polynomial ring");
284 if (v < 0 || v >= P->
n_vars())
286 ERROR(
"homogenization: improper ring variable");
289 if (wts.size() == 0 || wts.size() !=
static_cast<unsigned int>(P->
n_vars()))
291 ERROR(
"homogenization: improper weight function");
296 ERROR(
"homogenization: variable weight is zero");
301 if (
error())
return nullptr;
329 if (
R->lift(S,
val, g))
370 ERROR(
"fraction field or local ring required");
384 ERROR(
"fraction field or local rings required");
402 ERROR(
"fraction field required");
412 ERROR(
"local ring required");
417 ERROR(
"fraction field or local ring required");
422 std::vector<long> &result_coeffs)
const
425 const Ring *K =
R->getCoefficientRing();
426 if (
R ==
nullptr ||
R->n_vars() != 1)
429 "Expected a polynomial in a univariate polynomial ring");
435 result_coeffs.resize(0);
440 result_coeffs.resize(deg + 1);
441 for (
int i = 0; i <= deg; i++) result_coeffs[i] = 0;
449 result_coeffs.resize(0);
452 long coeff = res.second;
454 R->getMonoid()->to_expvector(t.monom, exp);
456 assert(exp[0] <= deg);
457 result_coeffs[exp[0]] = coeff;
464 std::vector<long> coeffs;
exponents::Exponents exponents_t
Ring-shaped wrapper that exposes a non-commutative FreeAlgebra to the rest of the engine.
ConcreteRing<RingType> — the templated bridge between aring and the legacy Ring API.
static EngineMonomial * make(int v, int e)
Engine-side immutable monomial value type wrapping a varpower- encoded exponent vector.
static void from_expvector(int n, exponents::ConstExponents a, Vector &result)
const Ring * get_ring() const
ring_elem numerator(ring_elem f) const
ring_elem denominator(ring_elem f) const
ring_elem fraction(const ring_elem top, const ring_elem bottom) const
Engine-side fraction field of a polynomial domain R_.
ring_elem numerator(ring_elem f) const
ring_elem fraction(const ring_elem top, const ring_elem bottom) const
ring_elem denominator(ring_elem f) const
const PolyRing * get_ring() const
Engine-side localisation of a polynomial ring at a prime ideal.
ring_elem lead_coefficient(const Ring *coeffRing, const Poly *f) const
Poly * get_terms(const Poly *f, int lo, int hi) const
Concrete Ring wrapper around an owned FreeAlgebra (no quotient).
Abstract Ring subclass that lifts either a FreeAlgebra or a FreeAlgebraQuotient into the engine's Rin...
virtual ring_elem get_coeff(const Ring *coeffR, const ring_elem f, const_varpower vp) const =0
virtual int n_logical_terms(int nvars0, const ring_elem f) const =0
virtual ring_elem homogenize(const ring_elem f, int v, int deg, const std::vector< int > &wts) const =0
virtual void lead_logical_exponents(int nvars0, const ring_elem f, exponents_t result_exp) const =0
virtual void degree_weights(const ring_elem f, const std::vector< int > &wts, int &lo, int &hi) const =0
virtual const Ring * getCoefficients() const
virtual ring_elem get_terms(int nvars0, const ring_elem f, int lo, int hi) const =0
virtual ring_elem lead_logical_coeff(const Ring *coeffR, const ring_elem f) const =0
Abstract base for the engine's polynomial-ring hierarchy.
virtual bool promote(const Ring *R, const ring_elem f, ring_elem &result) const =0
virtual unsigned int computeHashValue(const ring_elem a) const =0
virtual std::pair< bool, long > coerceToLongInteger(ring_elem a) const
virtual const PolynomialRing * cast_to_PolynomialRing() const
virtual const LocalRing * cast_to_LocalRing() const
virtual const FractionField * cast_to_FractionField() const
RingElement(const Ring *R, ring_elem f)
RingElement * power(mpz_srcptr n) const
RingElement * operator+(const RingElement &b) const
void text_out(buffer &o) const
RingElement * fraction(const Ring *R, const RingElement *bottom) const
static RingElement * random(const Ring *R)
bool is_homogeneous() const
EngineMonomial * lead_monom(int nvars) const
RingElement * denominator() const
RingElement * operator/(const RingElement &b) const
M2_arrayintOrNull getSmallIntegerCoefficients() const
ring_elem get_value() const
bool promote(const Ring *S, const RingElement *&result) const
const RingElement * split_off_content(const RingElement *&result) const
int n_terms(int nvars) const
RingElement * lead_coeff(const Ring *coeffR) const
RingElement * get_terms(int nvars, int lo, int hi) const
RingElement * numerator() const
RingElement * operator-() const
RingElement * invert() const
static RingElement * make_raw(const Ring *R, ring_elem f)
void degree_weights(const std::vector< int > &wts, int &lo, int &hi) const
const RingElement * remove_content() const
RingElement * get_coeff(const Ring *coeffR, const EngineMonomial *m) const
bool lift(const Ring *S, const RingElement *&result) const
const RingElement * content() const
const Ring * get_ring() const
virtual unsigned int computeHashValue() const
RingElement * homogenize(int v, const std::vector< int > &wts) const
RingElement * operator*(const RingElement &b) const
Engine-side ring of integers, backed by GMP mpz_ptr elements.
FractionField — field of fractions of an integral domain, with on-the-fly normalisation.
LocalRing — localisation of a polynomial ring at a prime ideal P.
VALGRIND_MAKE_MEM_DEFINED & result(result)
M2_arrayint M2_arrayintOrNull
Monoid — variable count, naming, grading, and monomial order of a polynomial ring.
EngineMonomial — opaque single-monomial value type used at the engine boundary.
typename std::vector< T, gc_allocator< T > > gc_vector
a version of the STL vector, which allocates its backing memory with gc.
#define newarray_atomic(T, len)
PolynomialRing — abstract polynomial-ring base, the engine's most-reused class.
RingElement — tagged (Ring*, ring_elem) pair, the engine's universal element type.
Singly linked-list node carrying one term of a polynomial-ring element.
M2_arrayint stdvector_to_M2_arrayint(const std::vector< T > &v)