Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::morphologies::Modular< N > Struct Template Referenceexport

\(\mathbb{Z}/N\mathbb{Z}\) as a total finite cyclic ring. More...

Collaboration diagram for dedekind::morphologies::Modular< N >:

Public Types

using machine_type = decltype(N)
using Domain = Modular
using wide_type

Public Member Functions

constexpr Modular (machine_type v=0)
constexpr Modular inverse () const
 The multiplicative inverse on a prime modulus, \(a^{N-2}\) (Fermat): ℤ/p is the field 𝔽ₚ.

Static Public Member Functions

static constexpr Modular generator ()
static constexpr Modular successor (Modular a)

Public Attributes

machine_type value

Static Public Attributes

static constexpr machine_type modulus = N
 The modulus N, as a value.

Friends

constexpr friend Modular operator+ (Modular a, Modular b)
constexpr friend Modular operator- (Modular a, Modular b)
constexpr friend Modular operator* (Modular a, Modular b)
constexpr friend Modular operator/ (Modular a, Modular b)
 Division on a prime modulus: multiplication by the inverse.
constexpr friend bool operator== (Modular a, Modular b)
constexpr friend std::weak_ordering constant_order (Modular a, Modular b)
 The structural order of residues as constants of a term (#884, canonical's sort key): their stored representatives compared. No order of the ring: ℤ/N has none compatible with its operations.

Detailed Description

template<auto N>
struct dedekind::morphologies::Modular< N >

\(\mathbb{Z}/N\mathbb{Z}\) as a total finite cyclic ring.

cyclic__The_Modular_Species

Relocated from dedekind.category:species into dedekind.morphologies:cyclic to live alongside the IsCyclic concept and its sibling carriers. The type satisfies both morphologies::IsCyclic (via the Domain / generator() / successor() member API) and dedekind::category::IsCyclicGroup<Modular<N>, std::plus<Modular<N>>> (via the trait specialisations below).

Member Typedef Documentation

◆ wide_type

template<auto N>
using dedekind::morphologies::Modular< N >::wide_type
Initial value:
std::conditional_t<(N == 1 ||
static_cast<std::uint64_t>(N - 1) <=
std::numeric_limits<std::uint64_t>::max() /
static_cast<std::uint64_t>(N - 1)),
unsigned long long, unsigned __int128>

Member Function Documentation

◆ inverse()

template<auto N>
Modular dedekind::morphologies::Modular< N >::inverse ( ) const
inlineconstexpr

The multiplicative inverse on a prime modulus, \(a^{N-2}\) (Fermat): ℤ/p is the field 𝔽ₚ.

Returns
the element whose product with this one is 1.
Exceptions
std::domain_errorfor 0, which has no inverse.

◆ operator/

template<auto N>
friend Modular operator/ ( Modular< N > a,
Modular< N > b )
friend

Division on a prime modulus: multiplication by the inverse.

Returns
\(a \cdot b^{-1}\).
Exceptions
std::domain_errorwhen b is 0.

The documentation for this struct was generated from the following file: