3#ifndef _aring_zz_gmp_hpp_
4#define _aring_zz_gmp_hpp_
72 size_t cardinality()
const {
return static_cast<size_t>(-1); }
75 return static_cast<unsigned int>(mpz_get_ui(&a));
84 return mpz_cmp_si(&f, 1) == 0 or mpz_cmp_si(&f, -1) == 0;
94 return mpz_cmp(&f, &g) == 0;
98 int cmp = mpz_cmp(&f, &g);
99 if (cmp > 0)
return 1;
100 if (cmp < 0)
return -1;
110 mpz_init_set(&
result, &a);
135 if (mpz_cmp_si(mpq_denref(a), 1) == 0)
191 mpz_submul(&
result, &a, &b);
207 if (mpz_divisible_p(&a, &b))
209 mpz_divexact(&
result, &a, &b);
219 return mpz_pow_ui(&
result, &a, n);
226 if (mpz_sgn(n) < 0)
throw exc::engine_error(
"can only raise to a nonnegative power");
229 mpz_pow_ui(&
result, &a, n1.second);
234 void syzygy(
const ElementType& a,
235 const ElementType& b,
237 ElementType& y)
const;
254 const ElementType& a,
257 bool p_parens =
false)
const;
305 const ElementType& f,
312 return mpz_fits_slong_p(&n);
Legacy RingZZ — a Ring-derived integer ring backed by GMP mpz_t.
Shared base of the aring framework (namespace M2) that unifies the engine's coefficient rings.
Append-only GC-backed byte buffer used throughout the engine for text output.
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
static const RingID ringID
void to_ring_elem(ring_elem &result, const ElementType &a) const
void subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
void set_from_mpz(ElementType &result, mpz_srcptr a) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
void init(ElementType &result) const
void invert(ElementType &result, const ElementType &a) const
void text_out(buffer &o) const
bool is_unit(const ElementType &f) const
int compare_elems(const ElementType &f, const ElementType &g) const
size_t characteristic() const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
void eval(const RingMap *map, const ElementType &f, int first_var, ring_elem &result) const
bool lift(const Ring *Rg, const ElementType &f, ring_elem &result) const
void set_var(ElementType &result, int v) const
bool promote(const Ring *Rf, const ring_elem f, ElementType &result) const
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
void init_set(ElementType &result, const ElementType &a) const
void add(ElementType &result, const ElementType &a, const ElementType &b) const
static void clear(ElementType &result)
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void power(ElementType &result, const ElementType &a, unsigned long n) const
void from_ring_elem(ElementType &result, const ring_elem &a) const
void set(ElementType &result, const ElementType &a) const
void set_zero(ElementType &result) const
void random(ElementType &result) const
size_t cardinality() const
void elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
bool coerceToLongInteger(long &result, const ElementType &n) const
const ElementType & from_ring_elem_const(const ring_elem &a) const
void negate(ElementType &result, const ElementType &a) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
exact division of integers.
bool is_equal(const ElementType &f, const ElementType &g) const
unsigned int computeHashValue(const elem &a) const
void set_from_long(ElementType &result, long a) const
bool is_zero(const ElementType &f) const
void swap(ElementType &a, ElementType &b) const
A base class for simple ARings.
Engine-side ring homomorphism: stores, for each source-ring variable, the target-ring element it maps...
static std::pair< bool, int > get_si(mpz_srcptr n)
namespace exc — internal C++ exception types and the TRY / CATCH macro pair.
void mpz_reallocate_limbs(mpz_ptr _z)
Inline helpers that move GMP / MPFR / MPFI limbs from malloc-managed storage into the bdwgc heap.
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define getmemstructtype(S)
void rawSetRandomInteger(mpz_ptr result, gmp_ZZ maxN)
Engine-boundary C API for the engine's PRNG and rational / real / complex random draws.
ring_elem — the universal value type carried by every Ring* in the engine.
mpz_srcptr get_mpz() const