C(++)ECCO
C++ Error Control COding: a header-only library for ECC simulations and experiments, modeling complete coding systems across arbitrary finite fields and complex inter-field relationships - Christian Senger <senger@inue.uni-stuttgart.de>
Loading...
Searching...
No Matches
CECCO::Embedding< SUBFIELD, SUPERFIELD > Class Template Reference

Functor representing the field embedding φ: SUBFIELD → SUPERFIELD, with reverse lookup. More...

#include <fields.hpp>

Public Member Functions

 Embedding ()
 Constructs the embedding (cached on first instantiation per template arguments).
constexpr SUPERFIELD operator() (const SUBFIELD &sub) const
 Apply φ: SUBFIELD → SUPERFIELD.
constexpr SUBFIELD extract (const SUPERFIELD &super) const
 Reverse φ: find the unique s ∈ SUBFIELD with φ(s) == super.

Detailed Description

template<FiniteFieldType SUBFIELD, FiniteFieldType SUPERFIELD>
requires SubfieldOf<SUPERFIELD, SUBFIELD>
class CECCO::Embedding< SUBFIELD, SUPERFIELD >

Functor representing the field embedding φ: SUBFIELD → SUPERFIELD, with reverse lookup.

Template Parameters
SUBFIELDSubfield (finite-field type)
SUPERFIELDSuperfield (finite-field type, must satisfy SubfieldOf<SUPERFIELD, SUBFIELD>)

Maps zero and one identically and preserves addition and multiplication. The identity map on labels is tried first: it is the natural embedding whenever SUBFIELD sits in the tower that defines the labels of SUPERFIELD (same field, prime subfield, plain Ext towers), and it is the unique choice consistent with label-based conversions such as Ext(const Vector<B>&) and as_vector(). Only for relationships where labels do not correspond (Iso-mediated towers) the image of a multiplicative generator is selected among the generators of the unique subgroup of SUPERFIELD* of order |SUBFIELD| − 1; candidates are accepted only when φ(x + 1) = φ(x) + 1 for every x, which together with multiplicativity implies additivity. The table is computed once per template instantiation and cached. Construction uses O(q) memory and O(q) time in the identity case, O(q²) in the worst case, for q = |SUBFIELD|; applying the resulting map is O(1).

Forward map (operator()) is an O(1) array lookup; extract reverses it via linear search through the cached map. When SUPERFIELD is an CECCO::Iso, extract walks the MAIN representation first, then each of OTHERS, until it finds one that contains SUBFIELD.

Warning
Mathematical containment is necessary but not sufficient: SUBFIELD must appear in the construction tower of SUPERFIELD (or in one of an Iso's components). Use an Iso to merge towers when needed.
Exceptions
std::logic_errorif the declared finite-field relationship admits no additive embedding

Usage_Example

using F2 = Fp<2>;
using F4 = Ext<F2, {1, 1, 1}>;
using F16 = Ext<F4, {2, 1, 1}>;
F4 a(2);
F16 b = phi(a); // upcast, always succeeds
F4 c = phi.extract(b); // throws std::invalid_argument if b ∉ φ(F4)
Embedding()
Constructs the embedding (cached on first instantiation per template arguments).
Definition fields.hpp:1358
Extension field 𝔽_{q^m} ≅ B[x]/(f(x)), constructed from a base field and an irreducible monic modulus...
Definition fields.hpp:2244
Prime field 𝔽_p ≅ ℤ/pℤ
Definition fields.hpp:1663

Definition at line 1322 of file fields.hpp.

Constructor & Destructor Documentation

◆ Embedding()

template<FiniteFieldType SUBFIELD, FiniteFieldType SUPERFIELD>
CECCO::Embedding< SUBFIELD, SUPERFIELD >::Embedding ( )

Constructs the embedding (cached on first instantiation per template arguments).

Definition at line 1358 of file fields.hpp.

Member Function Documentation

◆ extract()

template<FiniteFieldType SUBFIELD, FiniteFieldType SUPERFIELD>
SUBFIELD CECCO::Embedding< SUBFIELD, SUPERFIELD >::extract ( const SUPERFIELD & super) const
constexpr

Reverse φ: find the unique s ∈ SUBFIELD with φ(s) == super.

Exceptions
std::invalid_argumentif super is not in the image of φ

O(|SUBFIELD|) for regular fields; for Iso superfields, O(k · |SUBFIELD|) where k is the number of inspected components.

Definition at line 1365 of file fields.hpp.

◆ operator()()

template<FiniteFieldType SUBFIELD, FiniteFieldType SUPERFIELD>
SUPERFIELD CECCO::Embedding< SUBFIELD, SUPERFIELD >::operator() ( const SUBFIELD & sub) const
inlineconstexpr

Apply φ: SUBFIELD → SUPERFIELD.

Definition at line 1328 of file fields.hpp.


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