|
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>
|
Finite field arithmetic library. More...


Go to the source code of this file.
Classes | |
| class | CECCO::details::Base |
| Tag base for the CRTP-protection idiom. More... | |
| class | CECCO::details::Field< T > |
| CRTP base documenting the interface every field type must provide. More... | |
| class | CECCO::Rationals< T > |
| Field of rational numbers ℚ = { p/q : p, q ∈ ℤ, q ≠ 0 } with selectable precision. More... | |
| struct | CECCO::details::Lut1D< LabelType, FieldSize > |
| 1D lookup table for unary field operations (negation, inversion, order) More... | |
| struct | CECCO::details::Lut2D< LabelType, FieldSize > |
| 2D lookup table for commutative binary operations, optionally compressed More... | |
| struct | CECCO::details::Lut2Dcoeff< LabelType, ExtensionDegree, FieldSize > |
| Lookup table mapping each extension-field label to its base-field coefficient vector. More... | |
| struct | CECCO::details::LutHolderNoProvider< LutType, F, LutMode::CompileTime > |
| CompileTime specialisation: table is a constexpr static member. More... | |
| struct | CECCO::details::LutHolderNoProvider< LutType, F, LutMode::RunTime > |
| RunTime specialisation: thread-safe lazy initialisation on first access. More... | |
| struct | CECCO::details::LutHolder< LutType, ProviderLutType, P, F, LutMode::CompileTime > |
| CompileTime specialisation: table baked into the binary. More... | |
| struct | CECCO::details::LutHolder< LutType, ProviderLutType, P, F, LutMode::RunTime > |
| RunTime specialisation: thread-safe lazy initialisation, dependency resolved on first access. More... | |
| class | CECCO::Embedding< SUBFIELD, SUPERFIELD > |
| Functor representing the field embedding φ: SUBFIELD → SUPERFIELD, with reverse lookup. More... | |
| struct | CECCO::details::IsomorphismPair< A, B > |
| Shared static storage of the forward and reverse maps for the isomorphism A ↔ B. More... | |
| class | CECCO::Isomorphism< A, B > |
| Functor representing the field isomorphism φ: A → B between two same-size finite fields. More... | |
| class | CECCO::Fp< p > |
| Prime field 𝔽_p ≅ ℤ/pℤ More... | |
| class | CECCO::Ext< B, modulus, mode > |
| Extension field 𝔽_{q^m} ≅ B[x]/(f(x)), constructed from a base field and an irreducible monic modulus polynomial. More... | |
| class | CECCO::Iso< MAIN, OTHERS > |
| Single logical field unifying several pairwise-isomorphic representations. More... | |
Namespaces | |
| namespace | CECCO |
| Provides a framework for error correcting codes. | |
| namespace | CECCO::details |
| Contains implementation details not to be exposed to the user. Functions and classes here may change without notice. | |
Macros | |
| #define | CECCO_ERASURE_SUPPORT |
| Enables erase() / unerase() / is_erased() on every field type. | |
| #define | CECCO_USE_LUTS_FOR_FP |
| Force prime fields to use lookup tables instead of modular arithmetic. | |
| #define | CECCO_COMPRESS_LUTS_FROM_Q 256 |
| Compression threshold for 2D lookup tables in extension fields. | |
Typedefs | |
| template<uint16_t p, uint8_t m = 1> | |
| using | CECCO::label_t = typename std::conditional_t<sqm(p, m) < 255, uint8_t, uint16_t> |
Functions | |
| template<SignedIntType T> | |
| std::ostream & | CECCO::operator<< (std::ostream &os, const Rationals< T > &e) |
| Print as "numerator/denominator" (or just "numerator" when denominator is 1). | |
| template<uint16_t q, uint8_t m, size_t SIZE> | |
| static size_t constexpr | CECCO::details::integer_from_coeffs (const std::array< size_t, SIZE > &coeffs) noexcept |
| Encode polynomial coefficients (low-to-high) as a base-q integer label. | |
| template<typename LabelType, LabelType FieldSize> | |
| constexpr auto | CECCO::details::compute_multiplicative_orders (const Lut2D< LabelType, FieldSize > &mul_lut) |
| Build the table of multiplicative orders for all elements of 𝔽_Q. | |
| template<typename LabelType, LabelType FieldSize> requires (is_prime<LabelType>(FieldSize)) | |
| constexpr auto | CECCO::details::compute_multiplicative_inverses_direct () |
| Build multiplicative-inverse table for 𝔽_p via extended Euclidean algorithm. | |
| template<typename LabelType, LabelType FieldSize> | |
| constexpr auto | CECCO::details::compute_multiplicative_inverses_search (const Lut2D< LabelType, FieldSize > &mul_lut) |
| Build multiplicative-inverse table by searching the multiplication LUT. | |
| template<typename LabelType, LabelType FieldSize> requires (is_prime<LabelType>(FieldSize)) | |
| constexpr auto | CECCO::details::compute_additive_inverses_direct () |
| Build additive-inverse (negation) table for 𝔽_p. | |
| template<typename LabelType, LabelType FieldSize> | |
| constexpr auto | CECCO::details::compute_additive_inverses_search (const Lut2D< LabelType, FieldSize > &add_lut) |
| Build additive-inverse table by searching the addition LUT. | |
| template<typename LabelType, LabelType FieldSize> requires (is_prime<LabelType>(FieldSize)) | |
| constexpr auto | CECCO::details::compute_modular_addition_table () |
| Build the addition table for 𝔽_p: lut_add(a, b) = (a + b) mod p. | |
| template<typename F> | |
| constexpr F::label_t | CECCO::details::compute_primitive_root () |
| Smallest primitive root of F* by direct power enumeration. | |
| template<typename LabelType, LabelType FieldSize, typename LutCoeffType, uint8_t ExtensionDegree, typename BaseFieldType> | |
| constexpr auto | CECCO::details::compute_polynomial_addition_table (const LutCoeffType &lut_coeff) |
| Build the addition table for 𝔽_{q^m} via coefficient-wise base-field addition. | |
| template<typename FieldType> | |
| size_t | CECCO::details::calculate_multiplicative_order (const FieldType &element) |
Multiplicative order of element by repeated multiplication. | |
| template<typename LabelType, LabelType FieldSize> | |
| constexpr LabelType | CECCO::details::find_generator (const Lut1D< LabelType, FieldSize > &lut_mul_ord) |
| First element with multiplicative order Q − 1 (a generator of 𝔽_Q*). | |
| template<typename LabelType, LabelType FieldSize> requires (is_prime<LabelType>(FieldSize)) | |
| constexpr auto | CECCO::details::compute_modular_multiplication_table () |
| Build the multiplication table for 𝔽_p: lut_mul(a, b) = (a · b) mod p. | |
| template<typename LabelType, LabelType FieldSize, typename LutCoeffType, uint8_t ExtensionDegree, typename BaseFieldType, auto Modulus> | |
| constexpr auto | CECCO::details::compute_polynomial_multiplication_table (const LutCoeffType &lut_coeff) |
| Build the multiplication table for 𝔽_{q^m}: polynomial multiply, then reduce mod f(x). | |
| template<uint16_t p> | |
| std::ostream & | CECCO::operator<< (std::ostream &os, const Fp< p > &e) |
| Print as the integer label (or ERASURE_MARKER if erased). | |
| template<FiniteFieldType B, MOD modulus, LutMode mode> | |
| std::ostream & | CECCO::operator<< (std::ostream &os, const Ext< B, modulus, mode > &e) |
| Print as the integer label (or ERASURE_MARKER if erased). | |
Field Arithmetic Operators | |
Free CRTP operators (+, −, *, /, ^) for any CECCO::FieldType Each operator constructs a result by calling T's compound assignment, with rvalue overloads that move from a temporary instead of copying. Scalar multiplication takes the integer on either side. Division throws std::invalid_argument if the right operand is zero. operator^ exponentiates by square-and-multiply via CECCO::sqm.
| |
| template<FieldType T> | |
| constexpr T | CECCO::operator+ (const T &lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator+ (T &&lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator+ (const T &lhs, T &&rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator+ (T &&lhs, T &&rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator- (const T &lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator- (T &&lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator- (const T &lhs, T &&rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator- (T &&lhs, T &&rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (const T &lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (T &&lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (const T &lhs, T &&rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (T &&lhs, T &&rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (const T &lhs, uint16_t rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (uint16_t lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (T &&lhs, int rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator* (int lhs, T &&rhs) |
| template<FieldType T> | |
| T | CECCO::operator/ (const T &lhs, const T &rhs) |
| template<FieldType T> | |
| T | CECCO::operator/ (T &&lhs, const T &rhs) |
| template<FieldType T> | |
| constexpr T | CECCO::operator^ (const T &base, int exponent) |
| template<FieldType T> | |
| constexpr T | CECCO::operator^ (T &&base, int exponent) |
Variables | |
| constexpr std::string_view | CECCO::ERASURE_MARKER = "X" |
| template<typename LutType, LutType(*)() F> | |
| constexpr LutType | CECCO::details::LutHolderNoProvider< LutType, F, LutMode::CompileTime >::lut |
| template<typename LutType, typename ProviderLutType, const ProviderLutType &(*)() P, LutType(*)(const ProviderLutType &(*)()) F> | |
| constexpr LutType | CECCO::details::LutHolder< LutType, ProviderLutType, P, F, LutMode::CompileTime >::lut |
Finite field arithmetic library.
Licensed for noncommercial use only, including academic teaching, research, and personal non-profit purposes. Commercial use is prohibited without a separate commercial license. See the LICENSE file in the repository root for full terms and how to request a commercial license.
Finite-field arithmetic. The library provides:
A field tower in this library is a sequence of constructed extensions. Mathematical intermediate fields that were never constructed are not part of the tower. Two towers ending at isomorphic fields can be glued together by wrapping the two endpoints in an Iso.
CECCO::Ext requires the modulus to be a monic irreducible polynomial of degree ≥ 2, coefficients given low-to-high (constant term first). To find one inside the library:
Externally (Magma):
Definition in file fields.hpp.
| #define CECCO_COMPRESS_LUTS_FROM_Q 256 |
Compression threshold for 2D lookup tables in extension fields.
For fields with at least this many elements, the addition and multiplication tables store only the upper triangle (exploiting commutativity), saving ~50 % memory. Optimal value depends on cache size.
Definition at line 125 of file fields.hpp.
| #define CECCO_ERASURE_SUPPORT |
Enables erase() / unerase() / is_erased() on every field type.
Define only if needed (error-correction with erasures); enabling it costs some performance.
Definition at line 104 of file fields.hpp.
| #define CECCO_USE_LUTS_FOR_FP |
Force prime fields to use lookup tables instead of modular arithmetic.
Almost always slower than direct mod-p arithmetic — leave undefined unless you have a reason.
Definition at line 114 of file fields.hpp.