94 double v = 12347. * a.
re + 865800. * a.
im;
95 return static_cast<unsigned int>(v);
105 return f.
re == 0.0 and f.
im == 0.0;
110 return f.
re == g.
re and f.
im == g.
im;
115 double cmp_re = f.
re - g.
re;
116 if (cmp_re < 0)
return -1;
117 if (cmp_re > 0)
return 1;
118 double cmp_im = f.
im - g.
im;
119 if (cmp_im < 0)
return -1;
120 if (cmp_im > 0)
return 1;
173 result.re =
static_cast<double>(a);
198 result.re = mpfr_get_d(a, MPFR_RNDN);
204 result.re = mpfr_get_d(re, MPFR_RNDN);
205 result.im = mpfr_get_d(im, MPFR_RNDN);
210 result.re = mpfr_get_d(a->re, MPFR_RNDN);
211 result.im = mpfr_get_d(a->im, MPFR_RNDN);
238 if (fabs(a.re) >= fabs(a.im))
240 double p = a.im / a.re;
241 double denom = a.re +
p * a.im;
247 double p = a.re / a.im;
248 double denom = a.im +
p * a.re;
334 if (fabs(b.
re) >= fabs(b.
im))
337 denom = b.
re +
p * b.
im;
344 denom = b.
im +
p * b.
re;
385 mult(curr_pow, curr_pow, curr_pow);
401 const ElementType& a,
404 bool p_parens =
false)
const;
439 if (not
error())
ERROR(
"cannot coerce CC value to ring type");
450 mpfr_set_d(
result->re, a.
re, MPFR_RNDN);
451 mpfr_set_d(
result->im, a.
im, MPFR_RNDN);
463 if (mpfr_cmp_d(epsilon, fabs(a.
re)) > 0) a.
re = 0.0;
464 if (mpfr_cmp_d(epsilon, fabs(a.
im)) > 0) a.
im = 0.0;
471 if (mpfr_cmp_d(norm, d) < 0) mpfr_set_d(norm, d, MPFR_RNDN);
M2::ARingRR — machine-precision real numbers (IEEE 754 double).
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_long(ElementType &result, long a) const
void set_zero(ElementType &result) const
void text_out(buffer &o) const
void abs_squared(ARingRR::ElementType &result, const ElementType &a) const
void swap(ElementType &a, ElementType &b) const
RealRingType::ElementType RealElementType
void subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
void negate(ElementType &result, const ElementType &a) const
void invert(ElementType &res, const ElementType &a) const
void set(ElementType &result, const ElementType &a) const
void zeroize_tiny(gmp_RR epsilon, ElementType &a) const
unsigned int computeHashValue(const elem &a) const
void power(ElementType &result, const ElementType &a, int n) const
bool is_unit(const ElementType &f) const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void mult(ElementType &res, const ElementType &a, const RealElementType &b) const
void copy(ElementType &result, const ElementType &a) const
void add(ElementType &res, const ElementType &a, const ElementType &b) const
void set_from_doubles(ElementType &result, double re, double im) const
bool is_zero(const ElementType &f) const
void to_ring_elem(ring_elem &result, const ElementType &a) const
bool is_equal(const ElementType &f, const ElementType &g) const
const ElementType & from_ring_elem_const(const ring_elem &a) const
gmp_CC toBigComplex(const ElementType &a) const
int compare_elems(const ElementType &f, const ElementType &g) const
void abs(ARingRR::ElementType &result, const ElementType &a) const
void init(ElementType &result) const
void mult(ElementType &res, const ElementType &a, const ElementType &b) const
static const RingID ringID
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
const RealRingType & real_ring() const
void random(ElementType &result) const
void subtract(ElementType &res, const ElementType &a, const ElementType &b) const
void init_set(ElementType &result, const ElementType &a) const
void addMultipleTo(ElementType &res, const ElementType &a, const ElementType &b) const
void set_var(ElementType &result, int v) const
bool set_from_BigReals(ElementType &result, gmp_RR re, gmp_RR im) const
void set_from_mpz(ElementType &result, mpz_srcptr a) const
unsigned long get_precision() const
void divide(ElementType &res, const ElementType &a, const RealElementType &b) const
size_t characteristic() const
bool set_from_BigComplex(ElementType &result, gmp_CC a) const
void increase_norm(gmp_RRmutable norm, const ElementType &a) const
bool set_from_double(ElementType &result, double a) const
bool set_from_complex_double(ElementType &result, double re, double im) const
void elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
void divide(ElementType &res, const ElementType &a, const ElementType &b) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
void from_ring_elem(ElementType &result, const ring_elem &a) const
static void clear(ElementType &result)
void addMultipleTo(ElementType &res, const RealElementType &a, const ElementType &b) const
void eval(const RingMap *map, ElementType &f, int first_var, ring_elem &result) const
aring-style adapter for double-precision real numbers.
A base class for simple ARings.
virtual ring_elem from_long(long n) const =0
virtual bool from_complex_double(double re, double im, ring_elem &result) const
const Ring * get_ring() const
Engine-side ring homomorphism: stores, for each source-ring variable, the target-ring element it maps...
static std::pair< bool, int > get_si(mpz_srcptr n)
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
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
Engine-boundary C API for the engine's PRNG and rational / real / complex random draws.
cc_doubles_struct * cc_doubles_ptr
ring_elem — the universal value type carried by every Ring* in the engine.
RingMap — engine representation of a ring homomorphism.
cc_doubles_srcptr get_cc_doubles() const