number_field.hpp - Number Fields#

struct NumberField#

Models some features of a number field with an embedding into the real. In practice you won’t be using this struct directly, but just pass it into the factory of exactreal::Module to specify that the module should be considered over a certain number field.

#include <exact-real/number_field.hpp>
#include <exact-real/module.hpp>
#include <exact-real/real_number.hpp>
#include <e-antic/renf_class.hpp>
#include <e-antic/renf_elem_class.hpp>
#include <gmpxx.h>

auto K = eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1");
auto M = exactreal::Module<exactreal::NumberField>::make({exactreal::RealNumber::rational(1)}, exactreal::NumberField{K});
*M->ring().parameters
// -> NumberField(x^2 - 2, [1.414213562373095048801688724209698 +/- 1.96e-34])

Public Types

typedef eantic::renf_elem_class ElementClass#

The type modeling the elements of this field, i.e., e-antic’s renf_elem_class.

Public Functions

NumberField()#

Create the trivial number field, i.e., the rational field.

exactreal::NumberField Q;
*Q.parameters
// -> NumberField(a-1, [+/- 2.01])

NumberField(const eantic::renf_class&)#

Create the number field given by an e-antic field.

auto K = exactreal::NumberField{*eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1")};
*K.parameters
// -> NumberField(x^2 - 2, [1.414213562373095048801688724209698 +/- 1.96e-34])

NumberField(boost::intrusive_ptr<const eantic::renf_class>)#

Create the number field given by an e-antic field.

auto K = exactreal::NumberField{eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1")};
*K.parameters
// -> NumberField(x^2 - 2, [1.414213562373095048801688724209698 +/- 1.96e-34])

NumberField(const eantic::renf_elem_class&)#

Create the number field containing this number field element.

auto K = eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1");
auto N = exactreal::NumberField{K->one()};
*N.parameters
// -> NumberField(x^2 - 2, [1.414213562373095048801688724209698 +/- 1.96e-34])

ElementClass coerce(const ElementClass &x) const#

Return the number field element x as an element of this field.

Note that this is only implemented in trivial cases.

auto K = exactreal::NumberField{eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1")};
auto L = exactreal::NumberField{eantic::renf_class::make("y^3 - 2", "y", "1.4 +/- 1")};
auto x = K.coerce(L.parameters->one());
x.parent() == *K.parameters
// -> true

bool operator==(const NumberField&) const#

Return whether two number fields are identical.

auto K = exactreal::NumberField{eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1")};
auto L = exactreal::NumberField{eantic::renf_class::make("y^2 - 2", "y", "1.4 +/- 1")};
K == L
// -> false

Public Members

boost::intrusive_ptr<const eantic::renf_class> parameters#

Return the e-antic number field underlying this number field.

auto K = eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1");
exactreal::NumberField{K}.parameters == K
// -> true

Public Static Functions

static NumberField compositum(const NumberField &lhs, const NumberField &rhs)#

Return the smallest number field containing lhs and rhs.

Note that this method is only implemented in trivial cases currently.

auto K = exactreal::NumberField{eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1")};
auto L = exactreal::NumberField{};

auto M = exactreal::NumberField::compositum(K, L);
*M.parameters
// -> NumberField(x^2 - 2, [1.414213562373095048801688724209698 +/- 1.96e-34])

static bool unit(const ElementClass &x)#

Return whether the element x is a unit, i.e., whether it is non-zero.

auto K = eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1");
exactreal::NumberField::unit(K->gen())
// -> true

exactreal::NumberField::unit(K->zero())
// -> false

static mpz_class floor(const ElementClass &x)#

Return the integer floor of this number field element.

auto K = eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1");
exactreal::NumberField::floor(K->gen())
// -> 1

static Arb arb(const ElementClass &x, long prec)#

Return an approximation to the number field element x in ball arithmetic.

#include <exact-real/arb.hpp>
auto K = eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1");
exactreal::NumberField::arb(K->gen(), 64)
// -> [1.41421 +/- 3.57e-6]

static std::optional<mpq_class> rational(const ElementClass &x)#

Return the number field element x as a rational number, if possible.

auto K = eantic::renf_class::make("x^2 - 2", "x", "1.4 +/- 1");
exactreal::NumberField::rational(K->gen()).has_value()
// -> false

exactreal::NumberField::rational(K->one()).value()
// -> 1

template<typename T>
static ElementClass &imul(ElementClass &x, const T &t)#

Multiply the number field element x with t.

The argument may be a primitive integer, a GMP integer, a GMP rational, or another number field element.

template<typename T>
static ElementClass &idiv(ElementClass &x, const T &t)#

Divide the number field element x by t.

The argument may be a primitive integer, a GMP integer, a GMP rational, or another number field element.

Public Static Attributes

static bool contains_rationals = true#

Whether this number field contains the rational field, i.e., true.

static bool isField = true#

Whether this number field is a field, i.e., true.