76 typedef __mpfr_struct
elem;
87 double d = mpfr_get_d(&a, MPFR_RNDN);
88 return static_cast<unsigned int>(d);
99 return mpfr_cmp(&f, &g) == 0;
104 int cmp = mpfr_cmp(&f, &g);
105 if (cmp < 0)
return -1;
106 if (cmp > 0)
return 1;
121 mpfr_set(res, &a, MPFR_RNDN);
141 mpfr_set(&
result, &a, MPFR_RNDN);
146 mpfr_set(&
result, &a, MPFR_RNDN);
151 mpfr_set_si(&
result, 0, MPFR_RNDN);
157 mpfr_set(&
result, &a, MPFR_RNDN);
162 mpfr_set_si(&
result, a, MPFR_RNDN);
168 mpfr_set_si(&
result, 1, MPFR_RNDN);
173 mpfr_set_z(&
result, a, MPFR_RNDN);
178 mpfr_set_q(&
result, a, MPFR_RNDN);
184 mpfr_set_d(&
result, a, MPFR_RNDN);
189 mpfr_set(&
result, a, MPFR_RNDN);
196 mpfr_neg(&
result, &a, MPFR_RNDN);
202 mpfr_si_div(&
result, 1, &a, MPFR_RNDN);
209 mpfr_add(&
result, &a, &b, MPFR_RNDN);
223 mpfr_sub(&
result, &a, &b, MPFR_RNDN);
242 mpfr_mul(&
result, &a, &b, MPFR_RNDN);
249 mpfr_div(&
result, &a, &b, MPFR_RNDN);
254 mpfr_pow_si(&
result, &a, n, MPFR_RNDN);
259 mpfr_pow_z(&
result, &a, n, MPFR_RNDN);
264 const ElementType &a,
267 bool p_parens)
const;
300 ERROR(
"cannot coerce RRR value to ring type");
306 if (mpfr_cmpabs(&a, epsilon) < 0)
set_zero(a);
310 if (mpfr_cmpabs(&a, norm) > 0)
324 if (mpfr_cmp_si(&a, 0) < 0)
332 return mpfr_get_d(&a, MPFR_RNDN);
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.
size_t characteristic() const
void increase_norm(gmp_RRmutable norm, const ElementType &a) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void random(ElementType &result) const
void negate(ElementType &result, const ElementType &a) const
void invert(ElementType &result, const ElementType &a) const
bool is_equal(const ElementType &f, const ElementType &g) const
void subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
bool is_zero(const ElementType &f) const
void set_from_long(ElementType &result, long a) const
void addMultipleTo(ElementType &result, const ElementType &a, const ElementType &b) const
void eval(const RingMap *map, ElementType &f, int first_var, ring_elem &result) const
void set(ElementType &result, const ElementType &a) const
void abs(ElementType &result, const ElementType &a) const
ARingRRR(unsigned long precision)
void from_ring_elem(ElementType &result, const ring_elem &a) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
double coerceToDouble(const ElementType &a) const
int compare_elems(const ElementType &f, const ElementType &g) const
void to_ring_elem(ring_elem &result, const ElementType &a) const
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
void copy(ElementType &result, const ElementType &a) const
bool is_unit(const ElementType &f) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
static void clear(ElementType &result)
void power(ElementType &result, const ElementType &a, int n) const
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
void init_set(ElementType &result, const ElementType &a) const
const ElementType & from_ring_elem_const(const ring_elem &a) const
bool set_from_double(ElementType &result, double a) const
void init(ElementType &result) const
void set_from_mpz(ElementType &result, mpz_srcptr a) const
void text_out(buffer &o) const
void set_zero(ElementType &result) const
void abs_squared(ElementType &result, const ElementType &a) const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
void add(ElementType &result, const ElementType &a, const ElementType &b) const
void zeroize_tiny(gmp_RR epsilon, ElementType &a) const
void swap(ElementType &a, ElementType &b) const
unsigned int computeHashValue(const elem &a) const
unsigned long get_precision() const
void elem_text_out(buffer &o, const ElementType &a, bool p_one, bool p_plus, bool p_parens) const
static const RingID ringID
void set_var(ElementType &result, int v) const
A base class for simple ARings.
virtual bool from_BigReal(gmp_RR a, ring_elem &result) const
virtual ring_elem from_long(long n) const =0
const Ring * get_ring() const
Engine-side ring homomorphism: stores, for each source-ring variable, the target-ring element it maps...
mpfr_srcptr moveTo_gmpRR(mpfr_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 randomMpfr(mpfr_t result)
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.
RingMap — engine representation of a ring homomorphism.
mpfr_srcptr get_mpfr() const