91 double d1 = mpfr_get_d(&a.
re.left, MPFR_RNDN);
92 double d2 = mpfr_get_d(&(a.
re.right), MPFR_RNDN);
93 double d3 = mpfr_get_d(&(a.
im.left), MPFR_RNDN);
94 double d4 = mpfr_get_d(&(a.
im.right), MPFR_RNDN);
95 double d = 12347. * d1 + 865800. * d2 + 72158. * d3 + 86429. * d4;
96 return static_cast<unsigned int>(d);
104 bool is_zero(
const ElementType &f)
const {
return mpfr_cmp_si(&(f.
im.left), 0) == 0 and mpfr_cmp_si(&(f.
im.right), 0) == 0 and
105 mpfr_cmp_si(&(f.
re.left), 0) == 0 and
106 mpfr_cmp_si(&(f.
re.right), 0) == 0; }
109 mpfr_cmp(&(f.
re.left), &(g.
re.left)) == 0 and mpfr_cmp(&(f.
re.right), &(g.
re.right)) == 0 and
110 mpfr_cmp(&(f.
im.left), &(g.
im.left)) == 0 and mpfr_cmp(&(f.
im.right), &(g.
im.right)) == 0;
115 int cmp = mpfi_cmp(&f.
re, &g.
re);
116 if (cmp < 0)
return -1;
117 if (cmp > 0)
return 1;
118 cmp = mpfi_cmp(&f.
im, &g.
im);
119 if (cmp < 0)
return -1;
120 if (cmp > 0)
return 1;
147 mpfi_set(&res->
re,&a.
re);
148 mpfi_set(&res->
im,&a.
im);
185 mpfi_set(&
result.re, a->re);
186 mpfi_set(&
result.im, a->im);
191 mpfi_set_si(&
result.re, 0);
192 mpfi_set_si(&
result.im, 0);
207 mpfi_set_si(&
result.re, a);
208 mpfi_set_si(&
result.im, 0);
213 mpfi_set_si(&
result.re, v);
214 mpfi_set_si(&
result.im, 0);
219 mpfi_set_z(&
result.re, a);
220 mpfi_set_si(&
result.im, 0);
225 mpfi_set_q(&
result.re, a);
226 mpfi_set_si(&
result.im, 0);
232 mpfi_set_d(&
result.re, a);
233 mpfi_set_si(&
result.im, 0);
239 mpfi_set_fr(&
result.re, a);
240 mpfi_set_si(&
result.im, 0);
247 mpfi_set_si(&
result.im, 0);
253 mpfi_set_fr(&
result.re, a->re);
254 mpfi_set_fr(&
result.im, a->im);
267 mpfi_set_d(&
result.re, re);
268 mpfi_set_d(&
result.im, im);
274 mpfi_set(&
result.re, a->re);
275 mpfi_set(&
result.im, a->im);
288 mpfi_set_fr(&
result.re, re);
289 mpfi_set_fr(&
result.im, im);
293 mpfi_set_d(&
result.re, re);
294 mpfi_set_d(&
result.im, im);
328 mpfi_set(norm,&a.re);
329 mpfi_mul(norm,norm,norm);
330 mpfi_set(temp,&a.im);
331 mpfi_mul(temp,temp,temp);
332 mpfi_add(norm,norm,temp);
333 mpfi_set(&
result.re,&a.re);
334 mpfi_mul_si(&
result.im,&a.im,-1);
383 mpfi_t temp, retemp, imtemp;
387 mpfi_mul(retemp,&a.
re,&b.
re);
388 mpfi_mul(temp,&a.
im,&b.
im);
389 mpfi_sub(retemp,retemp,temp);
390 mpfi_mul(temp,&a.
re,&b.
im);
391 mpfi_mul(imtemp,&a.
im,&b.
re);
392 mpfi_add(&
result.im,imtemp,temp);
393 mpfi_set(&
result.re,retemp);
432 mpfi_set_si(&
result.re,1);
433 mpfi_set_si(&
result.im,0);
442 if (mpz_cmp_si(n,2)>=0)
446 mpz_fdiv_r_ui(r,n,2);
454 if (mpz_cmp_si(r,0) == 0)
456 mpz_cdiv_q_ui(m,n,2);
471 else if (mpz_cmp_si(n,1)==0)
476 else if (mpz_cmp_si(n,0)==0)
478 mpfi_set_si(&
result.re,1);
479 mpfi_set_si(&
result.im,0);
481 else if (mpz_cmp_si(n,0)<0)
486 mpfi_swap(&a.
re, &b.
re);
487 mpfi_swap(&a.
im, &b.
im);
491 mpfi_mid(&a.
re,&b.
re);
492 mpfi_mid(&a.
im,&b.
im);
499 mpfi_set(temp,&b.
im);
501 mpfi_add(&a,&a,temp);
506 const ElementType &a,
509 bool p_parens)
const;
534 mpfi_set_fr(&
result.re,val);
537 mpfi_put_fr(&
result.re,val);
540 mpfi_set_fr(&
result.im,val);
543 mpfi_put_fr(&
result.im,val);
559 ERROR(
"cannot coerce RRi value to ring type");
585 mpfi_set(temp,&a.
im);
589 mpfi_set_si(&
result.im,0);
M2::ARingCCC — arbitrary-precision complex numbers (pair of MPFR floats).
M2::ARingRRR — arbitrary-precision real numbers backed by MPFR.
M2::ARingRRi — certified real intervals [a, b] with MPFR endpoints, MPFI arithmetic.
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 abs(ElementType &result, const ElementType &a) const
static const RingID ringID
void zeroize_tiny(gmp_RR epsilon, ElementType &a) const
unsigned long get_precision() const
void set_imaginary_part(ElementType &c, ARingRRi::ElementType &a) const
void invert(ElementType &result, const ElementType &a) const
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
void add(ElementType &result, const ElementType &a, const ElementType &b) const
void set_from_mpz(ElementType &result, mpz_srcptr a) const
void eval(const RingMap *map, const ElementType &f, int first_var, ring_elem &result) const
void set_from_BigReals(ElementType &result, gmp_RR re, gmp_RR im) const
void set_var(ElementType &result, int v) const
void init_set(ElementType &result, const ElementType &a) const
bool is_member(mpq_srcptr a, const ElementType &f) const
void elem_text_out(buffer &o, const ElementType &a, bool p_one, bool p_plus, bool p_parens) const
bool is_member(double a, const ElementType &f) const
void to_ring_elem(ring_elem &result, const ElementType &a) const
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
void set(ElementType &result, const ElementType &a) const
void midpoint(ARingCCC::ElementType &a, const ElementType &b) const
bool set_from_BigComplex(ElementType &result, gmp_CC a) const
bool is_member(const ARingRRR::ElementType &a, const ElementType &f) const
void set_from_long(ElementType &result, long a) const
void set(ElementType &result, const gmp_CCi a) const
bool set_from_BigComplex(ElementType &result, const cc_struct *a) const
void negate(ElementType &result, const ElementType &a) const
void addMultipleTo(ElementType &result, const ElementType &a, const ElementType &b) const
bool set_from_complex_double(ElementType &result, double re, double im) const
void random(ElementType &result) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
void copy(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
void swap(ElementType &a, ElementType &b) const
bool is_empty(const ElementType &f) const
int compare_elems(const ElementType &f, const ElementType &g) const
bool is_subset(const ElementType &g, const ElementType &f) const
const ARingRRi::ElementType & realPartReference(const ElementType &a) const
unsigned int computeHashValue(const elem &a) const
static void clear(ElementType &result)
size_t characteristic() const
void from_ring_elem(ElementType &result, const ring_elem &a) const
void diameter(ARingRRi::ElementType &a, const ElementType &b) const
void increase_norm(gmp_RRmutable norm, const ElementType &a) const
bool set_from_ComplexInterval(ElementType &result, ElementType &a) const
void set_from_doubles(ElementType &result, double re, double im) const
void set_real_part(ElementType &c, ARingRRi::ElementType &a) const
bool set_from_double(ElementType &result, double a) const
bool is_member(const ARingCCC::ElementType &a, const ElementType &f) const
bool is_member(long a, const ElementType &f) const
void abs_squared(ElementType &result, const ElementType &a) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
gmp_CC toBigComplex(const ElementType &a) const
bool is_member(mpz_srcptr a, const ElementType &f) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
ARingCCi(unsigned long precision)
void init(ElementType &result) const
bool is_unit(const ElementType &f) const
bool is_zero(const ElementType &f) const
bool set_from_Interval(ElementType &result, gmp_RRi a) const
const ARingRRi::ElementType & imaginaryPartReference(const ElementType &a) const
void set_zero(ElementType &result) const
bool set_from_ComplexInterval(ElementType &result, gmp_CCi a) const
void power(ElementType &result, const ElementType &a, int n) const
const ElementType & from_ring_elem_const(const ring_elem &a) const
bool is_member(const ARingRRi::ElementType &a, const ElementType &f) const
void text_out(buffer &o) const
A base class for simple ARings.
virtual bool from_ComplexInterval(gmp_CCi z, 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...
void mpfi_reallocate_limbs(mpfi_ptr _z)
gmp_CC moveTo_gmpCC(gmp_CCmutable _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)
struct gmp_CC_struct * gmp_CC
struct gmp_CCmutable_struct * gmp_CCmutable
struct gmp_CCi_struct * gmp_CCi
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.
cci_srcptr get_cci() const