3#ifndef _aring_zz_flint_hpp_
4#define _aring_zz_flint_hpp_
49#include <M2/gc-include.h>
51#pragma GCC diagnostic push
52#pragma GCC diagnostic ignored "-Wconversion"
53#include <flint/flint.h>
54#include <flint/fmpz.h>
55#pragma GCC diagnostic pop
78 size_t cardinality()
const {
return static_cast<size_t>(-1); }
81 return static_cast<unsigned int>(fmpz_get_ui(&a));
90 return fmpz_is_one(&f) or fmpz_cmp_si(&f, -1) == 0;
100 return fmpz_equal(&f, &g);
104 int cmp = fmpz_cmp(&f, &g);
105 if (cmp > 0)
return 1;
106 if (cmp < 0)
return -1;
116 fmpz_init_set(&
result, &a);
140 if (mpz_cmp_si(mpq_denref(a), 1) == 0)
182 fmpz_add(&
result, &a, &b);
189 fmpz_sub(&
result, &a, &b);
196 fmpz_submul(&
result, &a, &b);
203 fmpz_mul(&
result, &a, &b);
211 if (fmpz_divisible(&a, &b))
213 fmpz_divexact(&
result, &a, &b);
222 const unsigned long n)
const
224 return fmpz_pow_ui(&
result, &a, n);
231 if (mpz_sgn(n) < 0)
throw exc::engine_error(
"can only raise to a nonnegative power");
234 fmpz_pow_ui(&
result, &a, n1.second);
239 void syzygy(
const ElementType& a,
240 const ElementType& b,
242 ElementType& y)
const;
259 const ElementType& a,
262 bool p_parens =
false)
const;
284 return PTR_TO_COEFF(a.
get_mpz());
309 const ElementType& f,
316 return fmpz_fits_si(&n);
Legacy RingZZ — a Ring-derived integer ring backed by GMP mpz_t.
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 subtract_multiple(ElementType &result, const ElementType &a, const ElementType &b) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
void swap(ElementType &a, ElementType &b) const
void from_ring_elem(ElementType &result, const ring_elem &a) const
void subtract(ElementType &result, const ElementType &a, const ElementType &b) const
void random(ElementType &result) const
bool is_zero(const ElementType &f) const
void add(ElementType &result, const ElementType &a, const ElementType &b) const
void text_out(buffer &o) const
bool promote(const Ring *Rf, const ring_elem f, ElementType &result) const
size_t cardinality() const
void set(ElementType &result, const ElementType &a) const
void invert(ElementType &result, const ElementType &a) const
bool is_unit(const ElementType &f) const
size_t characteristic() const
void init_set(ElementType &result, const ElementType &a) const
bool set_from_BigReal(ElementType &result, gmp_RR a) const
bool lift(const Ring *Rg, const ElementType &f, ring_elem &result) const
bool is_equal(const ElementType &f, const ElementType &g) const
unsigned int computeHashValue(const ElementType &a) const
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
bool coerceToLongInteger(long &result, const ElementType &n) const
void negate(ElementType &result, const ElementType &a) const
void set_zero(ElementType &result) const
static const RingID ringID
bool divide(ElementType &result, const ElementType &a, const ElementType &b) const
test doc
void syzygy(const ElementType &a, const ElementType &b, ElementType &x, ElementType &y) const
flint_rand_t mRandomState
void init(ElementType &result) const
void elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
int compare_elems(const ElementType &f, const ElementType &g) const
void set_var(ElementType &result, int v) const
void to_ring_elem(ring_elem &result, const ElementType &a) const
void eval(const RingMap *map, const ElementType &f, int first_var, ring_elem &result) const
bool set_from_mpq(ElementType &result, mpq_srcptr a) const
void power(ElementType &result, const ElementType &a, const unsigned long n) const
void set_from_long(ElementType &result, long a) const
static void clear(ElementType &result)
ElementType from_ring_elem_const(const ring_elem &a) const
void set_from_mpz(ElementType &result, mpz_srcptr a) const
A base class for simple ARings.
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_elem — the universal value type carried by every Ring* in the engine.
mpz_srcptr get_mpz() const