75 typedef __mpfi_struct
elem;
86 double d = 12347. * mpfr_get_d(&(a.left), MPFR_RNDN) + 865800. * mpfr_get_d(&(a.right), MPFR_RNDN);
87 return static_cast<unsigned int>(d);
95 bool is_zero(
const ElementType &f)
const {
return mpfr_cmp_si(&(f.left), 0) == 0 and mpfr_cmp_si(&(f.right), 0) == 0; }
98 return mpfr_cmp(&(f.left), &(g.left)) == 0 and mpfr_cmp(&(f.right), &(g.right)) == 0;
103 int cmp = mpfi_cmp(&f, &g);
104 if (cmp < 0)
return -1;
105 if (cmp > 0)
return 1;
211 mpfi_mul_si(&
result, &a, -1);
217 mpfi_si_div(&
result, 1, &a);
224 mpfi_add(&
result, &a, &b);
243 mpfi_sub(&
result, &a, &b);
262 mpfi_mul(&
result, &a, &b);
269 mpfi_div(&
result, &a, &b);
302 if (mpz_cmp_si(n,2)>=0)
306 mpz_fdiv_r_ui(r,n,2);
314 if (mpz_cmp_si(r,0) == 0)
316 mpz_cdiv_q_ui(m,n,2);
331 else if (mpz_cmp_si(n,1)==0)
333 else if (mpz_cmp_si(n,0)==0)
335 else if (mpz_cmp_si(n,0)<0)
350 const ElementType &a,
353 bool p_parens)
const;
388 ERROR(
"cannot coerce RRi value to ring type");
426 return mpfi_get_d(&a);
M2::ARingRRR — arbitrary-precision real numbers backed by MPFR.
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.
bool is_empty(const ElementType &f) const
void from_ring_elem(ElementType &result, const ring_elem &a) const
void init_set(ElementType &result, const ElementType &a) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
static void clear(ElementType &result)
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
bool is_zero(const ElementType &f) const
size_t characteristic() const
static const RingID ringID
void set_var(ElementType &result, int v) const
void left(ARingRRR::ElementType &a, const ElementType &b) const
void zeroize_tiny(gmp_RR epsilon, ElementType &a) const
void copy(ElementType &result, const ElementType &a) const
bool is_member(long a, const ElementType &f) const
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
void swap(ElementType &a, ElementType &b) const
void midpoint(ARingRRR::ElementType &a, const ElementType &b) const
void init(ElementType &result) const
void to_ring_elem(ring_elem &result, const ElementType &a) const
bool is_member(mpz_srcptr a, const ElementType &f) const
void random(ElementType &result) const
void negate(ElementType &result, const ElementType &a) const
void increase_norm(gmp_RRmutable norm, const ElementType &a) const
void set_zero(ElementType &result) const
bool set_from_Interval(ElementType &result, gmp_RRi a) const
const ElementType & from_ring_elem_const(const ring_elem &a) const
void subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
double coerceToDouble(const ElementType &a) const
bool is_subset(const ElementType &g, const ElementType &f) const
void addMultipleTo(ElementType &result, const ElementType &a, const ElementType &b) const
bool is_member(const ARingRRR::ElementType &a, const ElementType &f) const
void set(ElementType &result, const ElementType &a) const
void set_from_long(ElementType &result, long a) const
void add(ElementType &result, const ElementType &a, const ElementType &b) const
unsigned int computeHashValue(const elem &a) const
bool is_member(mpq_srcptr a, const ElementType &f) const
void set_from_mpz(ElementType &result, mpz_srcptr a) const
void invert(ElementType &result, const ElementType &a) const
void eval(const RingMap *map, const ElementType &f, int first_var, ring_elem &result) const
bool is_equal(const ElementType &f, const ElementType &g) const
int compare_elems(const ElementType &f, const ElementType &g) const
void power(ElementType &result, const ElementType &a, int n) const
bool is_unit(const ElementType &f) const
bool is_member(double a, const ElementType &f) const
ARingRRi(unsigned long precision)
void diameter(ARingRRR::ElementType &a, const ElementType &b) const
void right(ARingRRR::ElementType &a, const ElementType &b) const
void elem_text_out(buffer &o, const ElementType &a, bool p_one, bool p_plus, bool p_parens) const
unsigned long get_precision() const
void text_out(buffer &o) const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
void abs(ElementType &result, const ElementType &a) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
bool set_from_double(ElementType &result, double a) const
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void abs_squared(ElementType &result, const ElementType &a) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
A base class for simple ARings.
virtual bool from_Interval(gmp_RRi 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...
mpfi_srcptr moveTo_gmpRRi(mpfi_ptr _z)
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define getmemstructtype(S)
void rawSetRandomRRi(mpfi_ptr 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.
mpfi_srcptr get_mpfi() const