42 bool is_neg = (mpq_sgn(&a) == -1);
45 size_t size = mpz_sizeinbase(mpq_numref(&a), 10) +
46 mpz_sizeinbase(mpq_denref(&a), 10) + 3;
50 if (!is_neg && p_plus) o <<
'+';
58 str = mpq_get_str(allocstr, 10, &a);
61 if (size > 1000)
freemem(allocstr);
M2::ARingQQGMP — arbitrary-precision rationals backed straight by GMP mpq_t.
void negate(ElementType &result, const ElementType &a) const
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) 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 elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
void eval(const RingMap *map, const ElementType &f, int first_var, ring_elem &result) const
bool is_zero(const ElementType &f) const
virtual bool from_rational(const mpq_srcptr q, ring_elem &result) const =0
const Ring * get_ring() const
Engine-side ring homomorphism: stores, for each source-ring variable, the target-ring element it maps...
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define newarray_atomic(T, len)
Engine-boundary C API for the engine's PRNG and rational / real / complex random draws.
RingMap — engine representation of a ring homomorphism.