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::FieldType Concept Reference

Concept for field types: full algebraic interface. More...

#include <field_concepts_traits.hpp>

Concept definition

template<typename T>
concept FieldType =
std::is_base_of_v<details::Base, T> && !std::is_same_v<details::Base, T> && requires(const T& t, T& mutable_t) {
// Constructors (via constructibility checks)
requires std::constructible_from<T>; // Default constructor
requires std::copy_constructible<T>; // Copy constructor
requires std::move_constructible<T>; // Move constructor
requires std::constructible_from<T, int>; // From int constructor
// Assignment operators
{ mutable_t = t } -> std::same_as<T&>; // Field element assignment
{ mutable_t = 42 } -> std::same_as<T&>; // Integer assignment
// Compound assignment operators
{ mutable_t += t } -> std::same_as<T&>;
{ mutable_t -= t } -> std::same_as<T&>;
{ mutable_t *= t } -> std::same_as<T&>;
{ mutable_t /= t } -> std::same_as<T&>;
// Comparison operators
{ t == t } -> std::same_as<bool>;
// Unary - operator
{ -t } -> std::same_as<T>;
// Element properties
{ t.is_zero() } -> std::same_as<bool>;
{ t.has_positive_sign() } -> std::same_as<bool>;
{ t.get_characteristic() } -> std::convertible_to<size_t>;
{ t.get_info() } -> std::convertible_to<std::string>;
// Randomization
requires requires { mutable_t.randomize(); };
requires requires { mutable_t.randomize_force_change(); };
}
Concept for field types: full algebraic interface.

Detailed Description

Concept for field types: full algebraic interface.

Template Parameters
TCandidate type

Requires: compound assignments +=, −=, *=, /=; equality ==; unary ; default, copy, move, and int construction; assignment from T and from int; the property queries is_zero(), has_positive_sign(), get_characteristic(), get_info(); and the randomization methods randomize() / randomize_force_change(). The binary +, , *, / come for free from the CRTP operators in fields.hpp.

Usage_Example

template <FieldType F>
F discriminant(const F& a, const F& b, const F& c) {
return b * b - F(4) * a * c;
}
Note
Satisfied by CECCO::Rationals, CECCO::Fp, CECCO::Ext, and CECCO::Iso.

Definition at line 87 of file field_concepts_traits.hpp.