3#ifndef _aring_QQ_gmp_hpp_
4#define _aring_QQ_gmp_hpp_
75 size_t cardinality()
const {
return static_cast<size_t>(-1); }
78 unsigned long numhash = mpz_get_ui(mpq_numref(&a));
79 unsigned long denhash = mpz_get_ui(mpq_denref(&a));
80 return static_cast<unsigned int>(13253 * numhash + 7647 * denhash);
89 return (mpz_cmp_si(mpq_denref(&f), 1) == 0 and
90 (mpz_cmp_si(mpq_numref(&f), 1) == 0 or
91 mpz_cmp_si(mpq_numref(&f), -1) == 0));
102 return mpq_equal(&f, &g);
106 int cmp = mpq_cmp(&f, &g);
107 if (cmp > 0)
return 1;
108 if (cmp < 0)
return -1;
132 mpq_set_si(&
result, a, 1);
137 mpz_set(mpq_numref(&
result), a);
138 mpz_set_ui(mpq_denref(&
result), 1);
143 if (mpz_cmp_si(mpq_denref(&a), 1) == 0)
145 mpz_set(
result, mpq_numref(&a));
167 mpq_set_si(&
result, 1, 1);
210 mpq_mul(tmp, &a, &b);
233 bool n_is_negative =
false;
237 n_is_negative =
true;
240 mpz_pow_ui(mpq_numref(&
result), mpq_numref(&a), n);
241 mpz_pow_ui(mpq_denref(&
result), mpq_denref(&a), n);
257 void syzygy(
const ElementType& a,
258 const ElementType& b,
260 ElementType& y)
const;
272 mpz_add_ui(mpq_numref(&
result), mpq_numref(&
result), 1);
273 mpz_add_ui(mpq_denref(&
result), mpq_denref(&
result), 1);
274 mpq_canonicalize(&
result);
284 const ElementType& a,
287 bool p_parens =
false)
const;
319 printf(
"ARingQQGMP::calling promote\n");
337 void eval(
const RingMap* map,
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 set_from_mpz(ElementType &result, mpz_srcptr a) const
void negate(ElementType &result, const ElementType &a) const
bool invert(ElementType &result, const ElementType &a) const
size_t cardinality() const
size_t characteristic() const
const ElementType & from_ring_elem_const(const ring_elem &a) const
void from_ring_elem(ElementType &result, const ring_elem &a) const
bool is_unit(const ElementType &f) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
static void clear(ElementType &result)
void swap(ElementType &a, ElementType &b) const
std::vector< elem > ElementContainerType
void set_zero(ElementType &result) const
bool lift_to_mpz(mpz_ptr result, const ElementType &a) const
bool is_equal(const ElementType &f, const ElementType &g) const
void to_ring_elem(ring_elem &result, const ElementType &a) const
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
void set(ElementType &result, const ElementType &a) const
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
void random(ElementType &result) const
void subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
void set_from_long(ElementType &result, long a) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
test doc
bool is_pm_one(const ElementType &f) const
gmp_randstate_t mRandomState
void power(ElementType &result, const ElementType &a, long n) const
void add(ElementType &result, const ElementType &a, const ElementType &b) const
void set_var(ElementType &result, int v) const
int compare_elems(const ElementType &f, const ElementType &g) const
static const RingID ringID
void elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
unsigned int computeHashValue(const ElementType &a) const
void eval(const RingMap *map, const ElementType &f, int first_var, ring_elem &result) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
bool is_zero(const ElementType &f) const
void text_out(buffer &o) const
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void init_set(ElementType &result, const ElementType &a) const
void init(ElementType &result) const
A base class for simple ARings.
virtual bool is_ZZ() const
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 rawSetRandomQQ(mpq_ptr result, gmp_ZZ height)
Engine-boundary C API for the engine's PRNG and rational / real / complex random draws.
Ring — the legacy abstract base class for every coefficient and polynomial ring.
ring_elem — the universal value type carried by every Ring* in the engine.
mpq_srcptr get_mpq() const
mpz_srcptr get_mpz() const