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::Ext< B, modulus, mode > Class Template Reference

Extension field 𝔽_{q^m} ≅ B[x]/(f(x)), constructed from a base field and an irreducible monic modulus polynomial. More...

#include <fields.hpp>

Inheritance diagram for CECCO::Ext< B, modulus, mode >:
Inheritance graph

Public Types

using label_t = ::CECCO::label_t<Q>
using BASE_FIELD = B

Public Member Functions

constexpr Ext () noexcept
 Default constructor: 0.
 Ext (int l)
 Construct from an integer label l ∈ {0, …, Q − 1}; throws std::invalid_argument otherwise.
constexpr Ext (const Ext &other) noexcept=default
constexpr Ext (Ext &&other) noexcept=default
 Ext (const B &other)
 Embed a base-field element via the natural embedding B → Ext<B, modulus, mode>.
template<FiniteFieldType S, MOD ext_modulus, LutMode ext_mode>
 Ext (const Ext< S, ext_modulus, ext_mode > &other)
 Cross-field conversion from another extension field of the same characteristic.
template<FiniteFieldType T>
 Ext (const Vector< T > &v)
 Construct from a coefficient vector over a subfield.
template<FiniteFieldType MAIN, FiniteFieldType... OTHERS>
 Ext (const Iso< MAIN, OTHERS... > &other)
 Cross-field conversion from an Iso of the same characteristic.
template<uint16_t p>
requires SubfieldOf<Ext<B, modulus, mode>, Fp<p>> && (!std::is_same_v<B, Fp<p>>)
constexpr Ext (const Fp< p > &other)
 Embed a prime-field element when 𝔽_p is a (possibly indirect) subfield.
constexpr Extoperator= (int l)
 Assign integer label l ∈ {0, …, Q − 1}; throws std::invalid_argument otherwise.
constexpr Extoperator= (const Ext &rhs) noexcept=default
Extoperator= (Ext &&rhs) noexcept=default
template<FiniteFieldType S, MOD ext_modulus, LutMode ext_mode>
Extoperator= (const Ext< S, ext_modulus, ext_mode > &other)
 Cross-field assignment from another extension (copy-and-swap; same semantics as the constructor).
template<uint16_t p>
Extoperator= (const Fp< p > &other)
 Embed an Fp element of matching characteristic (copy-and-swap).
template<FiniteFieldType MAIN, FiniteFieldType... OTHERS>
Extoperator= (const Iso< MAIN, OTHERS... > &other)
 Cross-field assignment from an Iso of matching characteristic (copy-and-swap).
constexpr bool operator== (const Ext &rhs) const noexcept
constexpr Ext operator- () const &
 Additive inverse (lvalue): returns a new element.
constexpr Extoperator- () &&
 Additive inverse (rvalue): in place.
constexpr Extoperator+= (const Ext &rhs)
 *this += rhs via the addition LUT
constexpr Extoperator-= (const Ext &rhs)
 *this -= rhs via the addition LUT applied to −rhs
constexpr Extoperator*= (const Ext &rhs)
 *this *= rhs via the multiplication LUT
constexpr Extoperator*= (int s)
 Scalar multiplication by an int (repeated addition, reduced mod characteristic).
Extoperator/= (const Ext &rhs)
 *this /= rhs; throws std::invalid_argument if rhs is zero
Extrandomize ()
 Uniform random element in {0, …, Q − 1}.
Extrandomize_force_change ()
 Like randomize but guaranteed to differ from the current value.
size_t get_multiplicative_order () const
 Multiplicative order in the field's multiplicative group.
size_t get_additive_order () const
 Additive order: 1 for zero, characteristic p otherwise.
template<FiniteFieldType S = B>
requires SubfieldOf<Ext<B, modulus, mode>, S>
Polynomial< S > get_minimal_polynomial () const
 Minimal polynomial of this element over a subfield S (defaults to immediate base field B).
constexpr size_t get_label () const noexcept
 Underlying integer label in {0, …, Q − 1}.
constexpr bool has_positive_sign () const noexcept
 Always true (finite fields are unordered).
constexpr bool is_zero () const noexcept
 True iff this is the additive identity.
constexpr Exterase () noexcept
 Mark this element as erased (encoded as label == max(label_t)).
constexpr Extunerase () noexcept
 Clear the erasure flag, resetting to the additive identity.
constexpr bool is_erased () const noexcept
 Test whether this element is currently erased.
template<FiniteFieldType T = B>
Vector< T > as_vector () const
 Coordinate vector over a proper subfield T (defaults to the base field B).
template<FiniteFieldType T>
Isomorphism< Ext< B, modulus, mode >, T > isomorphism_to ()
template<FiniteFieldType S, MOD ext_modulus, LutMode ext_mode>
Ext< B, modulus, mode > & operator= (const Ext< S, ext_modulus, ext_mode > &rhs)
template<uint16_t p>
Ext< B, modulus, mode > & operator= (const Fp< p > &rhs)
template<FiniteFieldType MAIN, FiniteFieldType... OTHERS>
Ext< B, modulus, mode > & operator= (const Iso< MAIN, OTHERS... > &rhs)
Public Member Functions inherited from CECCO::details::Field< Ext< B, modulus, LutMode::RunTime > >
Ext< B, modulus, LutMode::RunTime > & operator= (int l)=delete
 Assign from int — derived must implement.
constexpr bool operator!= (const Ext< B, modulus, LutMode::RunTime > &rhs) const
 Inequality, defined as !(*this == rhs).
constexpr Ext< B, modulus, LutMode::RunTimeoperator+ () const &
 Unary + on an lvalue: returns a copy.
Ext< B, modulus, LutMode::RunTimeoperator- () const &noexcept=delete
 Additive inverse on an lvalue — derived must implement.
Ext< B, modulus, LutMode::RunTime > & operator+= (const Ext< B, modulus, LutMode::RunTime > &rhs) noexcept=delete
 *this += rhs — derived must implement
Ext< B, modulus, LutMode::RunTime > & operator-= (const Ext< B, modulus, LutMode::RunTime > &rhs) noexcept=delete
 *this -= rhs — derived must implement
Ext< B, modulus, LutMode::RunTime > & operator*= (const Ext< B, modulus, LutMode::RunTime > &rhs) noexcept=delete
 *this *= rhs — derived must implement
Ext< B, modulus, LutMode::RunTime > & operator/= (const Ext< B, modulus, LutMode::RunTime > &rhs)=delete
 *this /= rhs; throws std::invalid_argument if rhs is zero — derived must implement
Fieldrandomize ()=delete
 Uniform random element of the field — derived must implement; may return the same value.
Fieldrandomize_force_change ()=delete
 Like randomize but guaranteed to differ from the current value — derived must implement.
size_t get_multiplicative_order () const=delete
 Smallest k > 0 with this^k == 1; throws std::invalid_argument if *this is zero.
size_t get_additive_order () const=delete
 Smallest k > 0 with k * *this == 0; for finite fields of characteristic p this is p (or 1 for zero); for ℚ it is 1 for zero and 0 (infinite) otherwise.
bool has_positive_sign () const noexcept=delete
 True if the element is "positive" (always true for finite fields; sign of numerator for ℚ).
bool is_zero () const noexcept=delete
 True if *this is the additive identity.
Fielderase () noexcept=delete
 Mark this element as erased (out-of-field marker for erasure decoding).
Fieldunerase () noexcept=delete
 Clear the erasure flag, resetting to additive identity.
bool is_erased () const noexcept=delete
 Test whether this element is currently erased.

Static Public Member Functions

static std::string get_info ()
 Human-readable description (size, base field, modulus).
static constexpr size_t get_characteristic () noexcept
static constexpr bool is_constexpr_ready () noexcept
 True for LutMode::CompileTime, false for LutMode::RunTime.
static constexpr Polynomial< B > get_modulus ()
 Modulus polynomial f(x) — the irreducible used to construct this field.
static Ext get_generator ()
 Generator (primitive element) of the multiplicative group.
static constexpr size_t get_p () noexcept
static constexpr size_t get_m () noexcept
static constexpr size_t get_q () noexcept
static constexpr size_t get_size () noexcept
template<FiniteFieldType T>
static Isomorphism< Ext, T > isomorphism_to ()
 Isomorphism mapping Ext → T for any Isomorphic<Ext, T> target.
static void show_tables ()
 Print all lookup tables to std::cout (debugging aid).
static constexpr bool ready ()
 Compile-time signal that all LUTs are constructed.

Precomputed Lookup Tables

Compile-time generated tables for field operations

using LUT_COEFF = details::LutHolderNoProvider<Lut2Dcoeff, lambda, mode>
using LUT_ADD = details::LutHolder<Lut2D, Lut2Dcoeff, &lut_coeff, &compute_add_lut_wrapper, mode>
using LUT_MUL = details::LutHolder<Lut2D, Lut2Dcoeff, &lut_coeff, &compute_mul_lut_wrapper, mode>
using LUT_NEG = details::LutHolder<Lut1D, Lut2D, &lut_add, &compute_neg_lut_wrapper, mode>
using LUT_INV = details::LutHolder<Lut1D, Lut2D, &lut_mul, &compute_inv_lut_wrapper, mode>
using LUT_MUL_ORD = details::LutHolder<Lut1D, Lut2D, &lut_mul, &compute_mul_ord_lut_wrapper, mode>
using LUT_GEN = details::LutHolder<Gen, Lut1D, &lut_mul_ord, &compute_generator_wrapper, mode>
static constexpr auto lambda
 Element coefficients: lut_coeff[i] = polynomial coefficients of element i.
static constexpr bool luts_ready
static constexpr auto & lut_coeff ()
static constexpr Lut2D compute_add_lut_wrapper (const Lut2Dcoeff &(*provider)())
 Addition table: lut_add(a,b) = (polynomial_a + polynomial_b) mod f(X).
static constexpr auto & lut_add ()
static constexpr Lut2D compute_mul_lut_wrapper (const Lut2Dcoeff &(*provider)())
 Multiplication table: lut_mul(a,b) = (polynomial_a * polynomial_b) mod f(X).
static constexpr auto & lut_mul ()
static constexpr Lut1D compute_neg_lut_wrapper (const Lut2D &(*provider)())
 Additive inverse table: lut_neg[a] = -a.
static constexpr auto & lut_neg ()
static constexpr Lut1D compute_inv_lut_wrapper (const Lut2D &(*provider)())
 Multiplicative inverse table: lut_inv[a] = a^(-1).
static constexpr auto & lut_inv ()
static constexpr Lut1D compute_mul_ord_lut_wrapper (const Lut2D &(*provider)())
 Multiplicative order table: lut_mul_ord[a] = order of a in multiplicative group.
static constexpr auto & lut_mul_ord ()
static constexpr Gen compute_generator_wrapper (const Lut1D &(*provider)())
 Primitive element (generator) of the multiplicative group.
static constexpr auto & g ()
static constexpr label_t lut_add (label_t a, label_t b)
static constexpr label_t lut_mul (label_t a, label_t b)
static constexpr label_t lut_neg (label_t a)
static constexpr label_t lut_inv (label_t a)

Additional Inherited Members

Protected Member Functions inherited from CECCO::details::Field< Ext< B, modulus, LutMode::RunTime > >
 ~Field () noexcept=default
Protected Member Functions inherited from CECCO::details::Base
 Base ()=default

Detailed Description

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
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.

Template Parameters
BBase field, either CECCO::Fp, another CECCO::Ext, or CECCO::Iso
modulusCoefficients of f(x) low-to-high (constant term first); leading coefficient must be 1, degree m ≥ 2; f(x) must be irreducible over B
modeCECCO::LutMode::RunTime (default) or CECCO::LutMode::CompileTime

The result has q = |B| and Q = q^m elements; elements are stored as label_t integers in {0, …, Q − 1}. Towers are built by re-using Ext as the base. Pick CompileTime for small fields (zero startup, larger binary) or RunTime for large fields (faster compilation, lazy initialisation on first use). LUT modes mix freely across a tower; a CompileTime extension can only be built when its base satisfies CECCO::Ext::is_constexpr_ready.

Warning
A non-irreducible modulus is detected during LUT construction and surfaces as std::invalid_argument at runtime, or as a constexpr-evaluation error at compile time when mode == LutMode::CompileTime. Use CECCO::find_irreducible to obtain a valid one.

Usage_Example

using F3 = Fp<3>;
using F9 = Ext<F3, {2, 2, 1}>; // 𝔽₃[x]/(2 + 2x + x²)
using F27 = Ext<F9, {1, 2, 1}>; // 3-level tower 𝔽₃ ⊂ 𝔽₉ ⊂ 𝔽₂₇
F9 a(5), b(7);
auto c = a * b + F9(1); // arithmetic
Vector<F3> coeffs = a.as_vector<F3>(); // coefficient vector over the prime subfield
size_t ord = a.get_multiplicative_order();
F27 x(100);
Vector<F3> v = x.as_vector<F3>(); // descend straight to the prime subfield
Extension field 𝔽_{q^m} ≅ B[x]/(f(x)), constructed from a base field and an irreducible monic modulus...
Definition fields.hpp:2221
size_t get_multiplicative_order() const
Multiplicative order in the field's multiplicative group.
Definition fields.hpp:2934
constexpr Ext() noexcept
Default constructor: 0.
Definition fields.hpp:2238
Prime field 𝔽_p ≅ ℤ/pℤ
Definition fields.hpp:1647

Definition at line 2221 of file fields.hpp.

Member Typedef Documentation

◆ BASE_FIELD

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::BASE_FIELD = B

Definition at line 2235 of file fields.hpp.

◆ label_t

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::label_t = ::CECCO::label_t<Q>

Definition at line 2234 of file fields.hpp.

◆ LUT_ADD

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::LUT_ADD = details::LutHolder<Lut2D, Lut2Dcoeff, &lut_coeff, &compute_add_lut_wrapper, mode>

Definition at line 2503 of file fields.hpp.

◆ LUT_COEFF

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::LUT_COEFF = details::LutHolderNoProvider<Lut2Dcoeff, lambda, mode>

Definition at line 2495 of file fields.hpp.

◆ LUT_GEN

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::LUT_GEN = details::LutHolder<Gen, Lut1D, &lut_mul_ord, &compute_generator_wrapper, mode>

Definition at line 2543 of file fields.hpp.

◆ LUT_INV

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::LUT_INV = details::LutHolder<Lut1D, Lut2D, &lut_mul, &compute_inv_lut_wrapper, mode>

Definition at line 2527 of file fields.hpp.

◆ LUT_MUL

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::LUT_MUL = details::LutHolder<Lut2D, Lut2Dcoeff, &lut_coeff, &compute_mul_lut_wrapper, mode>

Definition at line 2511 of file fields.hpp.

◆ LUT_MUL_ORD

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::LUT_MUL_ORD = details::LutHolder<Lut1D, Lut2D, &lut_mul, &compute_mul_ord_lut_wrapper, mode>

Definition at line 2535 of file fields.hpp.

◆ LUT_NEG

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
using CECCO::Ext< B, modulus, mode >::LUT_NEG = details::LutHolder<Lut1D, Lut2D, &lut_add, &compute_neg_lut_wrapper, mode>

Definition at line 2519 of file fields.hpp.

Constructor & Destructor Documentation

◆ Ext() [1/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
CECCO::Ext< B, modulus, mode >::Ext ( )
inlineconstexprnoexcept

Default constructor: 0.

Definition at line 2238 of file fields.hpp.

◆ Ext() [2/9]

template<FiniteFieldType B, MOD modulus, LutMode mode>
CECCO::Ext< B, modulus, mode >::Ext ( int l)

Construct from an integer label l ∈ {0, …, Q − 1}; throws std::invalid_argument otherwise.

Definition at line 2576 of file fields.hpp.

◆ Ext() [3/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
CECCO::Ext< B, modulus, mode >::Ext ( const Ext< B, modulus, mode > & other)
constexprdefaultnoexcept

◆ Ext() [4/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
CECCO::Ext< B, modulus, mode >::Ext ( Ext< B, modulus, mode > && other)
constexprdefaultnoexcept

◆ Ext() [5/9]

template<FiniteFieldType B, MOD modulus, LutMode mode>
CECCO::Ext< B, modulus, mode >::Ext ( const B & other)

Embed a base-field element via the natural embedding B → Ext<B, modulus, mode>.

Definition at line 2582 of file fields.hpp.

◆ Ext() [6/9]

template<FiniteFieldType B, MOD modulus, LutMode mode>
template<FiniteFieldType S, MOD ext_modulus, LutMode ext_mode>
CECCO::Ext< B, modulus, mode >::Ext ( const Ext< S, ext_modulus, ext_mode > & other)

Cross-field conversion from another extension field of the same characteristic.

Template Parameters
SBase of the source extension field
ext_modulusModulus of the source extension field
Exceptions
std::invalid_argumenton a downcast whose source value lies outside the target

Picks the cheapest available path: direct copy if the type matches; cached Isomorphism for isomorphic fields; cached Embedding for tower relationships (upcast cannot fail, downcast may); two-step conversion via details::largest_common_subfield_t for unrelated towers.

Definition at line 2618 of file fields.hpp.

◆ Ext() [7/9]

template<FiniteFieldType B, MOD modulus, LutMode mode>
template<FiniteFieldType T>
CECCO::Ext< B, modulus, mode >::Ext ( const Vector< T > & v)

Construct from a coefficient vector over a subfield.

Template Parameters
TSubfield type
Exceptions
std::invalid_argumentif v.length() does not match the extension degree of this field over T

Reads v as base-|T| coefficients (low-to-high). With CECCO_ERASURE_SUPPORT, an erased component in v produces an erased element here.

Definition at line 2663 of file fields.hpp.

◆ Ext() [8/9]

template<FiniteFieldType B, MOD modulus, LutMode mode>
template<FiniteFieldType MAIN, FiniteFieldType... OTHERS>
CECCO::Ext< B, modulus, mode >::Ext ( const Iso< MAIN, OTHERS... > & other)

Cross-field conversion from an Iso of the same characteristic.

Delegates to the Ext(other.main()) overload, letting the Ext-to-Ext logic choose the conversion path; works equally for downcasts, upcasts, and cross-tower bridges.

Exceptions
std::invalid_argumentif no conversion path exists

Definition at line 2718 of file fields.hpp.

◆ Ext() [9/9]

template<FiniteFieldType B, MOD modulus, LutMode mode>
requires SubfieldOf<Ext<B, modulus, mode>, Fp<p>> && (!std::is_same_v<B, Fp<p>>)
template<uint16_t p>
requires SubfieldOf<Ext<B, modulus, mode>, Fp<p>> && (!std::is_same_v<B, Fp<p>>)
CECCO::Ext< B, modulus, mode >::Ext ( const Fp< p > & other)
constexpr

Embed a prime-field element when 𝔽_p is a (possibly indirect) subfield.

Uses the cached Embedding from Fp<p> to this Ext; cannot fail for any value permitted by SubfieldOf<Ext, Fp<p>>.

Definition at line 2793 of file fields.hpp.

Member Function Documentation

◆ as_vector()

template<FiniteFieldType B, MOD modulus, LutMode mode>
template<FiniteFieldType T>
Vector< T > CECCO::Ext< B, modulus, mode >::as_vector ( ) const

Coordinate vector over a proper subfield T (defaults to the base field B).

Template Parameters
TSubfield (SubfieldOf<Ext, T> and T ≠ Ext)
Returns
Vector of length [Ext : T]; round-trip through the Ext(Vector<T>) constructor
F16 x(10);
Vector<F4> v4 = x.as_vector<F4>(); // length 2
Vector<F2> v2 = x.as_vector<F2>(); // length 4
F16 y = F16(v2); // round trip
Vector v = (v₀, v₁, …, vₙ₋₁) over a CECCO::ComponentType.
Definition vectors.hpp:115

Definition at line 3006 of file fields.hpp.

◆ compute_add_lut_wrapper()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr Lut2D CECCO::Ext< B, modulus, mode >::compute_add_lut_wrapper ( const Lut2Dcoeff &(* provider )())
inlinestaticconstexpr

Addition table: lut_add(a,b) = (polynomial_a + polynomial_b) mod f(X).

Definition at line 2499 of file fields.hpp.

◆ compute_generator_wrapper()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr Gen CECCO::Ext< B, modulus, mode >::compute_generator_wrapper ( const Lut1D &(* provider )())
inlinestaticconstexpr

Primitive element (generator) of the multiplicative group.

Definition at line 2539 of file fields.hpp.

◆ compute_inv_lut_wrapper()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr Lut1D CECCO::Ext< B, modulus, mode >::compute_inv_lut_wrapper ( const Lut2D &(* provider )())
inlinestaticconstexpr

Multiplicative inverse table: lut_inv[a] = a^(-1).

Definition at line 2523 of file fields.hpp.

◆ compute_mul_lut_wrapper()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr Lut2D CECCO::Ext< B, modulus, mode >::compute_mul_lut_wrapper ( const Lut2Dcoeff &(* provider )())
inlinestaticconstexpr

Multiplication table: lut_mul(a,b) = (polynomial_a * polynomial_b) mod f(X).

Definition at line 2507 of file fields.hpp.

◆ compute_mul_ord_lut_wrapper()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr Lut1D CECCO::Ext< B, modulus, mode >::compute_mul_ord_lut_wrapper ( const Lut2D &(* provider )())
inlinestaticconstexpr

Multiplicative order table: lut_mul_ord[a] = order of a in multiplicative group.

Definition at line 2531 of file fields.hpp.

◆ compute_neg_lut_wrapper()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr Lut1D CECCO::Ext< B, modulus, mode >::compute_neg_lut_wrapper ( const Lut2D &(* provider )())
inlinestaticconstexpr

Additive inverse table: lut_neg[a] = -a.

Definition at line 2515 of file fields.hpp.

◆ erase()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::erase ( )
constexprnoexcept

Mark this element as erased (encoded as label == max(label_t)).

Warning
Erased elements must not participate in field arithmetic — see CECCO_ERASURE_SUPPORT.

Definition at line 2603 of file fields.hpp.

◆ g()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr auto & CECCO::Ext< B, modulus, mode >::g ( )
inlinestaticconstexpr

Definition at line 2544 of file fields.hpp.

◆ get_additive_order()

template<FiniteFieldType B, MOD modulus, LutMode mode>
size_t CECCO::Ext< B, modulus, mode >::get_additive_order ( ) const

Additive order: 1 for zero, characteristic p otherwise.

Definition at line 2943 of file fields.hpp.

◆ get_characteristic()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr size_t CECCO::Ext< B, modulus, mode >::get_characteristic ( )
inlinestaticconstexprnoexcept

Definition at line 2374 of file fields.hpp.

◆ get_generator()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > CECCO::Ext< B, modulus, mode >::get_generator ( )
static

Generator (primitive element) of the multiplicative group.

Smallest label with multiplicative order |field| − 1; cached statically.

Definition at line 2993 of file fields.hpp.

◆ get_info()

template<FiniteFieldType B, MOD modulus, LutMode mode>
std::string CECCO::Ext< B, modulus, mode >::get_info ( )
static

Human-readable description (size, base field, modulus).

Definition at line 2973 of file fields.hpp.

◆ get_label()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
size_t CECCO::Ext< B, modulus, mode >::get_label ( ) const
inlineconstexprnoexcept

Underlying integer label in {0, …, Q − 1}.

Definition at line 2376 of file fields.hpp.

◆ get_m()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr size_t CECCO::Ext< B, modulus, mode >::get_m ( )
inlinestaticconstexprnoexcept

Definition at line 2397 of file fields.hpp.

◆ get_minimal_polynomial()

template<FiniteFieldType B, MOD modulus, LutMode mode>
requires SubfieldOf<Ext<B, modulus, mode>, S>
template<FiniteFieldType S>
requires SubfieldOf<Ext<B, modulus, mode>, S>
Polynomial< S > CECCO::Ext< B, modulus, mode >::get_minimal_polynomial ( ) const

Minimal polynomial of this element over a subfield S (defaults to immediate base field B).

Template Parameters
SSubfield (SubfieldOf<Ext, S>)

Computed from the S-conjugacy orbit { α, α^{|S|}, α^{|S|²}, … } as the polynomial whose roots are exactly those conjugates. Useful for working with polynomials over an intermediate or the prime subfield in a tower.

F16 alpha = F16::get_generator();
auto over_F4 = alpha.get_minimal_polynomial<F4>();
auto over_F2 = alpha.get_minimal_polynomial<F2>(); // absolute

Definition at line 2953 of file fields.hpp.

◆ get_modulus()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Polynomial< B > CECCO::Ext< B, modulus, mode >::get_modulus ( )
staticconstexpr

Modulus polynomial f(x) — the irreducible used to construct this field.

Definition at line 2982 of file fields.hpp.

◆ get_multiplicative_order()

template<FiniteFieldType B, MOD modulus, LutMode mode>
size_t CECCO::Ext< B, modulus, mode >::get_multiplicative_order ( ) const

Multiplicative order in the field's multiplicative group.

Exceptions
std::invalid_argumentif *this is zero

Definition at line 2934 of file fields.hpp.

◆ get_p()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr size_t CECCO::Ext< B, modulus, mode >::get_p ( )
inlinestaticconstexprnoexcept

Definition at line 2396 of file fields.hpp.

◆ get_q()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr size_t CECCO::Ext< B, modulus, mode >::get_q ( )
inlinestaticconstexprnoexcept

Definition at line 2398 of file fields.hpp.

◆ get_size()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr size_t CECCO::Ext< B, modulus, mode >::get_size ( )
inlinestaticconstexprnoexcept

Definition at line 2399 of file fields.hpp.

◆ has_positive_sign()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
bool CECCO::Ext< B, modulus, mode >::has_positive_sign ( ) const
inlineconstexprnoexcept

Always true (finite fields are unordered).

Definition at line 2409 of file fields.hpp.

◆ is_constexpr_ready()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr bool CECCO::Ext< B, modulus, mode >::is_constexpr_ready ( )
inlinestaticconstexprnoexcept

True for LutMode::CompileTime, false for LutMode::RunTime.

Used by extensions further up in a tower to gate their own CompileTime instantiation (a CompileTime field cannot be built on a RunTime base).

Definition at line 2384 of file fields.hpp.

◆ is_erased()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
bool CECCO::Ext< B, modulus, mode >::is_erased ( ) const
inlineconstexprnoexcept

Test whether this element is currently erased.

Definition at line 2424 of file fields.hpp.

◆ is_zero()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
bool CECCO::Ext< B, modulus, mode >::is_zero ( ) const
inlineconstexprnoexcept

True iff this is the additive identity.

Definition at line 2411 of file fields.hpp.

◆ isomorphism_to() [1/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<FiniteFieldType T>
Isomorphism< Ext< B, modulus, mode >, T > CECCO::Ext< B, modulus, mode >::isomorphism_to ( )

Definition at line 2597 of file fields.hpp.

◆ isomorphism_to() [2/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<FiniteFieldType T>
Isomorphism< Ext, T > CECCO::Ext< B, modulus, mode >::isomorphism_to ( )
static

Isomorphism mapping Ext → T for any Isomorphic<Ext, T> target.

◆ lut_add() [1/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr auto & CECCO::Ext< B, modulus, mode >::lut_add ( )
inlinestaticconstexpr

Definition at line 2504 of file fields.hpp.

◆ lut_add() [2/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr label_t CECCO::Ext< B, modulus, mode >::lut_add ( label_t a,
label_t b )
inlinestaticconstexpr

Definition at line 2548 of file fields.hpp.

◆ lut_coeff()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr auto & CECCO::Ext< B, modulus, mode >::lut_coeff ( )
inlinestaticconstexpr

Definition at line 2496 of file fields.hpp.

◆ lut_inv() [1/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr auto & CECCO::Ext< B, modulus, mode >::lut_inv ( )
inlinestaticconstexpr

Definition at line 2528 of file fields.hpp.

◆ lut_inv() [2/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr label_t CECCO::Ext< B, modulus, mode >::lut_inv ( label_t a)
inlinestaticconstexpr

Definition at line 2551 of file fields.hpp.

◆ lut_mul() [1/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr auto & CECCO::Ext< B, modulus, mode >::lut_mul ( )
inlinestaticconstexpr

Definition at line 2512 of file fields.hpp.

◆ lut_mul() [2/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr label_t CECCO::Ext< B, modulus, mode >::lut_mul ( label_t a,
label_t b )
inlinestaticconstexpr

Definition at line 2549 of file fields.hpp.

◆ lut_mul_ord()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr auto & CECCO::Ext< B, modulus, mode >::lut_mul_ord ( )
inlinestaticconstexpr

Definition at line 2536 of file fields.hpp.

◆ lut_neg() [1/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr auto & CECCO::Ext< B, modulus, mode >::lut_neg ( )
inlinestaticconstexpr

Definition at line 2520 of file fields.hpp.

◆ lut_neg() [2/2]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr label_t CECCO::Ext< B, modulus, mode >::lut_neg ( label_t a)
inlinestaticconstexpr

Definition at line 2550 of file fields.hpp.

◆ operator*=() [1/2]

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator*= ( const Ext< B, modulus, mode > & rhs)
constexpr

*this *= rhs via the multiplication LUT

Definition at line 2884 of file fields.hpp.

◆ operator*=() [2/2]

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator*= ( int s)
constexpr

Scalar multiplication by an int (repeated addition, reduced mod characteristic).

Definition at line 2893 of file fields.hpp.

◆ operator+=()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator+= ( const Ext< B, modulus, mode > & rhs)
constexpr

*this += rhs via the addition LUT

Definition at line 2866 of file fields.hpp.

◆ operator-() [1/2]

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator- ( ) &&
constexpr

Additive inverse (rvalue): in place.

Definition at line 2857 of file fields.hpp.

◆ operator-() [2/2]

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > CECCO::Ext< B, modulus, mode >::operator- ( ) const &
constexpr

Additive inverse (lvalue): returns a new element.

Definition at line 2847 of file fields.hpp.

◆ operator-=()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator-= ( const Ext< B, modulus, mode > & rhs)
constexpr

*this -= rhs via the addition LUT applied to −rhs

Definition at line 2875 of file fields.hpp.

◆ operator/=()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator/= ( const Ext< B, modulus, mode > & rhs)

*this /= rhs; throws std::invalid_argument if rhs is zero

Definition at line 2904 of file fields.hpp.

◆ operator=() [1/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
Ext & CECCO::Ext< B, modulus, mode >::operator= ( const Ext< B, modulus, mode > & rhs)
constexprdefaultnoexcept

◆ operator=() [2/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<FiniteFieldType S, MOD ext_modulus, LutMode ext_mode>
Ext & CECCO::Ext< B, modulus, mode >::operator= ( const Ext< S, ext_modulus, ext_mode > & other)

Cross-field assignment from another extension (copy-and-swap; same semantics as the constructor).

◆ operator=() [3/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<FiniteFieldType S, MOD ext_modulus, LutMode ext_mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator= ( const Ext< S, ext_modulus, ext_mode > & rhs)

Definition at line 2822 of file fields.hpp.

◆ operator=() [4/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<uint16_t p>
Ext & CECCO::Ext< B, modulus, mode >::operator= ( const Fp< p > & other)

Embed an Fp element of matching characteristic (copy-and-swap).

◆ operator=() [5/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<uint16_t p>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator= ( const Fp< p > & rhs)

Definition at line 2831 of file fields.hpp.

◆ operator=() [6/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<FiniteFieldType MAIN, FiniteFieldType... OTHERS>
Ext & CECCO::Ext< B, modulus, mode >::operator= ( const Iso< MAIN, OTHERS... > & other)

Cross-field assignment from an Iso of matching characteristic (copy-and-swap).

◆ operator=() [7/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
template<FiniteFieldType MAIN, FiniteFieldType... OTHERS>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator= ( const Iso< MAIN, OTHERS... > & rhs)

Definition at line 2840 of file fields.hpp.

◆ operator=() [8/9]

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
Ext & CECCO::Ext< B, modulus, mode >::operator= ( Ext< B, modulus, mode > && rhs)
defaultnoexcept

◆ operator=() [9/9]

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::operator= ( int l)
constexpr

Assign integer label l ∈ {0, …, Q − 1}; throws std::invalid_argument otherwise.

Definition at line 2813 of file fields.hpp.

◆ operator==()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
bool CECCO::Ext< B, modulus, mode >::operator== ( const Ext< B, modulus, mode > & rhs) const
inlineconstexprnoexcept

Definition at line 2319 of file fields.hpp.

◆ randomize()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::randomize ( )

Uniform random element in {0, …, Q − 1}.

Definition at line 2914 of file fields.hpp.

◆ randomize_force_change()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::randomize_force_change ( )

Like randomize but guaranteed to differ from the current value.

Definition at line 2924 of file fields.hpp.

◆ ready()

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
constexpr bool CECCO::Ext< B, modulus, mode >::ready ( )
inlinestaticconstexpr

Compile-time signal that all LUTs are constructed.

Used by extensions further up in a tower to defer their own LUT computation until this one is fully instantiated, preventing compiler recursion-depth issues. The implementation is the constexpr luts_ready flag, which forces immediate evaluation of every LUT on a CompileTime instantiation.

Warning
Only well-defined after all LUT declarations in the class body have been seen.

Definition at line 2454 of file fields.hpp.

◆ show_tables()

template<FiniteFieldType B, MOD modulus, LutMode mode>
void CECCO::Ext< B, modulus, mode >::show_tables ( )
static

Print all lookup tables to std::cout (debugging aid).

Definition at line 3037 of file fields.hpp.

◆ unerase()

template<FiniteFieldType B, MOD modulus, LutMode mode>
Ext< B, modulus, mode > & CECCO::Ext< B, modulus, mode >::unerase ( )
constexprnoexcept

Clear the erasure flag, resetting to the additive identity.

Definition at line 2609 of file fields.hpp.

Member Data Documentation

◆ lambda

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
auto CECCO::Ext< B, modulus, mode >::lambda
staticconstexpr
Initial value:
= []() constexpr -> Lut2Dcoeff {
Lut2Dcoeff lut_coeff;
for (label_t i = 0; i < Q; ++i) {
lut_coeff.values[i][m - 1] = i % q;
label_t t = q;
for (uint8_t s = 1; s < m; ++s) {
lut_coeff.values[i][m - 1 - s] = (i / t) % q;
t *= q;
}
}
return lut_coeff;
}
static constexpr auto & lut_coeff()
Definition fields.hpp:2496
::CECCO::label_t< Q > label_t
Definition fields.hpp:2234

Element coefficients: lut_coeff[i] = polynomial coefficients of element i.

Definition at line 2479 of file fields.hpp.

◆ luts_ready

template<FiniteFieldType B, MOD modulus, LutMode mode = LutMode::RunTime>
bool CECCO::Ext< B, modulus, mode >::luts_ready
staticconstexpr
Initial value:
= []() constexpr {
static_assert(B::ready());
if constexpr (mode == LutMode::CompileTime) {
static_assert(lut_coeff().values[0][0] == 0);
static_assert(lut_add()(0, 0) == 0);
static_assert(lut_neg()(0) == 0);
static_assert(lut_mul()(0, 1) == 0);
static_assert(lut_mul_ord()(0) == 0);
static_assert(g().value != 1);
}
return true;
}()
static constexpr auto & g()
Definition fields.hpp:2544
static constexpr auto & lut_mul()
Definition fields.hpp:2512
static constexpr auto & lut_add()
Definition fields.hpp:2504
static constexpr auto & lut_mul_ord()
Definition fields.hpp:2536
static constexpr auto & lut_neg()
Definition fields.hpp:2520
@ CompileTime
Generate LUTs at compile-time using constexpr (default).

Definition at line 2553 of file fields.hpp.


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