3#ifndef _aring_QQ_flint_hpp_
4#define _aring_QQ_flint_hpp_
42#include <M2/gc-include.h>
44#pragma GCC diagnostic push
45#pragma GCC diagnostic ignored "-Wconversion"
46#include <flint/flint.h>
47#include <flint/fmpq.h>
48#include <flint/fmpz.h>
49#pragma GCC diagnostic pop
80 size_t cardinality()
const {
return static_cast<size_t>(-1); }
83 unsigned long numhash = fmpz_get_ui(fmpq_numref(&a));
84 unsigned long denhash = fmpz_get_ui(fmpq_denref(&a));
85 return static_cast<unsigned int>(13253 * numhash + 7647 * denhash);
94 return fmpq_is_one(&f) or ((fmpz_cmp_si(fmpq_numref(&f), -1) == 0) and
95 fmpz_is_one(fmpq_denref(&f)));
106 return fmpq_equal(&f, &g);
110 int cmp = fmpq_cmp(&f, &g);
111 if (cmp > 0)
return 1;
112 if (cmp < 0)
return -1;
136 fmpq_set_si(&
result, a, 1);
142 fmpz_set_mpz(fmpq_numref(&
result), a);
143 fmpz_one(fmpq_denref(&
result));
162 fmpq_set_si(&
result, 1, 1);
189 fmpq_add(&
result, &a, &b);
196 fmpq_sub(&
result, &a, &b);
203 fmpq_submul(&
result, &a, &b);
210 fmpq_mul(&
result, &a, &b);
219 fmpq_div(&
result, &a, &b);
224 return fmpq_pow_si(&
result, &a, n);
238 void syzygy(
const ElementType& a,
239 const ElementType& b,
241 ElementType& y)
const;
258 const ElementType& a,
261 bool p_parens =
false)
const;
290 result.num = PTR_TO_COEFF(mpq_numref(a1));
291 result.den = PTR_TO_COEFF(mpq_denref(a1));
321 const ElementType& f,
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 init_set(ElementType &result, const ElementType &a) const
void add(ElementType &result, const ElementType &a, const ElementType &b) const
flint_rand_t mRandomState
void init(ElementType &result) const
bool promote(const Ring *Rf, const ring_elem f, ElementType &result) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
test doc
static const RingID ringID
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
bool is_equal(const ElementType &f, const ElementType &g) const
void from_ring_elem(ElementType &result, const ring_elem &a) const
void eval(const RingMap *map, const ElementType &f, int first_var, ring_elem &result) const
static void clear(ElementType &result)
void elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
void text_out(buffer &o) const
void swap(ElementType &a, ElementType &b) const
void set_var(ElementType &result, int v) const
void negate(ElementType &result, const ElementType &a) const
bool is_pm_one(const ElementType &f) const
void subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
unsigned int computeHashValue(const ElementType &a) const
size_t cardinality() const
void power(ElementType &result, const ElementType &a, long n) const
void to_ring_elem(ring_elem &result, const ElementType &a) const
const ElementType from_ring_elem_const(const ring_elem &a) const
returns a read only view into the ring_elem The return value of this function should not be modified,...
void random(ElementType &result) const
bool invert(ElementType &result, const ElementType &a) const
int compare_elems(const ElementType &f, const ElementType &g) const
size_t characteristic() const
void set_from_long(ElementType &result, long a) const
bool lift(const Ring *Rg, const ElementType &f, ring_elem &result) const
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
void set(ElementType &result, const ElementType &a) const
void set_from_mpz(ElementType &result, mpz_srcptr a) const
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
bool is_zero(const ElementType &f) const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
void set_zero(ElementType &result) const
bool is_unit(const ElementType &f) const
A base class for simple ARings.
virtual bool is_ZZ() 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)
namespace exc — internal C++ exception types and the TRY / CATCH macro pair.
void mpz_reallocate_limbs(mpz_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)
Ring — the legacy abstract base class for every coefficient and polynomial ring.
ring_elem — the universal value type carried by every Ring* in the engine.
mpq_srcptr get_mpq() const
mpz_srcptr get_mpz() const