integer_ring.hpp - Integers#
-
struct IntegerRing#
Implements integer arithmetic for integer coefficients in expressions making up an Element.
There should be no need to instantiate this struct. It’s usually only used as a template parameter:
#include <exact-real/module.hpp> #include <exact-real/real_number.hpp> #include <exact-real/element.hpp> #include <exact-real/integer_ring.hpp> auto M = exactreal::Module<exactreal::IntegerRing>::make({ exactreal::RealNumber::rational(1), exactreal::RealNumber::random()}); *M // -> ℤ-Module(1, ℝ(<...>))
Public Types
-
typedef mpz_class ElementClass#
The internal representation of element of this ring, i.e., GMP integers.
Public Functions
-
IntegerRing()#
Create the integer ring.
-
IntegerRing(const mpz_class&)#
Create “an” integer ring that contains the argument.
This is identical to IntegerRing::IntegerRing() but other rings, say number fields, have different rings and need to be able to construct the smallest ring that contains a certain element.
-
ElementClass coerce(const ElementClass &x) const#
Convert the integer argument into this integer ring, i.e., just return the integer unchanged.
Number fields need the equivalent of this method to convert elements between different number fields.
-
bool operator==(const IntegerRing &R) const#
Return whether this integer ring is identical to
R
, i.e., returntrue
since there is only one integer ring.
Public Static Functions
-
static IntegerRing compositum(const IntegerRing &lhs, const IntegerRing &rhs)#
Return the integer ring that contains both arguments.
This is just the IntegerRing::IntegerRing() but other rings need such functionality to compute a composite ring.
-
static bool unit(const ElementClass &x)#
Return whether
x
is a unit, i.e., whether it is 1 or -1.
-
static Arb arb(const ElementClass &x, long prec)#
Return an (exact) Arb approximation of the integer
x
.#include <exact-real/arb.hpp> exactreal::IntegerRing::arb(1, 64) // -> 1.00000
-
static mpz_class floor(const ElementClass &x)#
Return the floor of the integer
x
, i.e., the element unchanged.
-
static std::optional<mpq_class> rational(const ElementClass &x)#
Return the integer
x
as a rational number.exactreal::IntegerRing::rational(1).value() // -> 1
-
template<typename T>
static ElementClass &imul(ElementClass &x, const T &t)# Multiply the integer
x
witht
.The argument may be a primitive integer, a GMP integer, or a GMP rational that is an integer.
-
template<typename T>
static ElementClass &idiv(ElementClass &x, const T &t)# Divide the integer
x
byt
.The argument may be a primitive integer, a GMP integer, or a GMP rational. This operation is only supported if the result of the exact division is an integer.
-
typedef mpz_class ElementClass#