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>)

The embedding is determined by mapping a generator: with factor = (|SUPERFIELD| − 1) / (|SUBFIELD| − 1), it sends g_sub^k ↦ g_super^{k · factor}. Identities φ(0) = 0, φ(1) = 1 are fixed. The full table is computed once per template instantiation and cached.

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.

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:1337
Extension field 𝔽_{q^m} ≅ B[x]/(f(x)), constructed from a base field and an irreducible monic modulus...
Definition fields.hpp:2221
Prime field 𝔽_p ≅ ℤ/pℤ
Definition fields.hpp:1647

Definition at line 1301 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 1337 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 1346 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 1307 of file fields.hpp.


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