module.hpp - Submodules of the Reals#

template<typename Ring>
class Module#

A submodule of the real numbers.

Use make to create a module.

#include <exact-real/module.hpp>
#include <exact-real/real_number.hpp>
#include <exact-real/element.hpp>
#include <exact-real/integer_ring.hpp>
#include <exact-real/rational_field.hpp>
#include <exact-real/number_field.hpp>

auto M = exactreal::Module<exactreal::IntegerRing>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
*M
// -> -Module(1, (<...>))

Note that modules are always wrapped in a shared pointer so that elements can keep their module alive.

Public Types

using Basis = std::vector<std::shared_ptr<const RealNumber>>#

The generators of a module are (independent) real numbers.

Public Functions

const Ring &ring() const#

Return the Ring underlying this module.

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::RealNumber::random()}, exactreal::NumberField{K});
*M->ring().parameters
// -> NumberField(x^2 - 2, [1.414213562373095048801688724209698 +/- 1.96e-34])

size rank() const#

Return the rank of this module, i.e., the number of generators.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
M->rank()
// -> 2

bool submodule(const Module &other) const#

Return whether this module is trivially a submodule of other i.e., whether all the generators of this module are also generators of other.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
auto N = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1)});
M->submodule(*N)
// -> false

N->submodule(*M)
// -> true

const Basis &basis() const#

Return the generators of this module.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
M->basis().size()
// -> 2

Element<Ring> gen(size i) const#

Return the i-th generator of this module.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
M->gen(0)
// -> 1

Element<Ring> zero() const#

Return the zero element in this module.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
M->zero()
// -> 0

Element<Ring> one() const#

Return a one element in this module. If there is no such element, an exception is raised.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
M->one()
// -> 1

bool operator==(const Module<Ring> &rhs) const#

Return whether two modules are indistinguishable, i.e., they have the same generators in the same order and are defined over the same ring.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
auto N = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1)});

*M == *N
// -> false

*M != *N
// -> true

Public Static Functions

static std::shared_ptr<const Module<Ring>> make(const Basis&)#

Create a module with the given generators over the trivial Ring.

This function is meant to be used with rings that are not parametrized, such as the integer or the rationals.

auto M = exactreal::Module<exactreal::RationalField>::make({
  exactreal::RealNumber::rational(1),
  exactreal::RealNumber::random()});
*M
// -> -Module(1, (<...>))

static std::shared_ptr<const Module<Ring>> make(const Basis&, const Ring&)#

Create a module with the given generators over the given Ring.

#include <e-antic/renf_class.hpp>
#include <e-antic/renf_elem_class.hpp>
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::RealNumber::random()}, exactreal::NumberField{K});
*M
// -> K-Module(1, (<...>))

static std::shared_ptr<const Module<Ring>> span(const std::shared_ptr<const Module<Ring>>&, const std::shared_ptr<const Module<Ring>>&)#

Friends

template<typename R>
friend std::ostream &operator<<(std::ostream&, const Module<R>&)#