17#ifndef MATRIX_FIELD_Z2_OPERATORS_H_
18#define MATRIX_FIELD_Z2_OPERATORS_H_
37 using isUnsignedInteger = std::enable_if_t<std::is_unsigned_v<T> >;
39 using isInteger = std::enable_if_t<std::is_integral_v<T> >;
58 template <
typename Integer_type,
class = isInteger<Integer_type> >
61 if constexpr (std::is_same_v<Integer_type, bool>) {
64 return e < 2 && e >= 0 ? e : e % 2;
76 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
77 static Element add(Unsigned_integer_type e1, Unsigned_integer_type e2)
79 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
94 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
95 static void add_inplace(Unsigned_integer_type& e1, Unsigned_integer_type e2)
97 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
112 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
115 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
130 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
133 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
148 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
151 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
166 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
169 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
184 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
187 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
203 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
206 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
207 return (e && m) != a;
222 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
225 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
241 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
244 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
261 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
264 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
265 return (e != a) && m;
280 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
283 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
299 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
302 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
318 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
319 static bool are_equal(Unsigned_integer_type e1, Unsigned_integer_type e2)
321 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
335 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
338 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
353 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
Class defining operators for the field.
Definition Z2_field_operators.h:32
static void add_inplace(Unsigned_integer_type &e1, Unsigned_integer_type e2)
Stores in the first element the sum of two given elements in the field, that is (e1 + e2) % 2,...
Definition Z2_field_operators.h:95
static Element multiply_and_add(Unsigned_integer_type e, Unsigned_integer_type m, Unsigned_integer_type a)
Multiplies the first element with the second one and adds the third one. Returns the result in the fi...
Definition Z2_field_operators.h:204
static void subtract_inplace_front(Unsigned_integer_type &e1, Unsigned_integer_type e2)
Stores in the first element the subtraction in the field of the first element by the second element,...
Definition Z2_field_operators.h:131
static Element get_value(Integer_type e)
Returns the value of an integer in the field. That is the positive value of the integer modulo the cu...
Definition Z2_field_operators.h:59
static void add_and_multiply_inplace_back(Unsigned_integer_type &e, Unsigned_integer_type a, Unsigned_integer_type m)
Adds the first element to the second one and multiplies the third one with it, that is ((e + a) * m) ...
Definition Z2_field_operators.h:300
static constexpr Element get_multiplicative_identity()
Returns the multiplicative identity of the field.
Definition Z2_field_operators.h:372
static constexpr Element get_additive_identity()
Returns the additive identity of the field.
Definition Z2_field_operators.h:365
static std::pair< Element, Characteristic > get_partial_inverse(Unsigned_integer_type e, Characteristic productOfCharacteristics)
For interface purposes with multi-fields. Returns the inverse together with the second argument.
Definition Z2_field_operators.h:354
static Element subtract(Unsigned_integer_type e1, Unsigned_integer_type e2)
Returns the subtraction in the field of the first element by the second element.
Definition Z2_field_operators.h:113
static constexpr Characteristic get_characteristic()
Returns the characteristic of the field, that is 2.
Definition Z2_field_operators.h:48
static void subtract_inplace_back(Unsigned_integer_type e1, Unsigned_integer_type &e2)
Stores in the second element the subtraction in the field of the first element by the second element,...
Definition Z2_field_operators.h:149
static void multiply_and_add_inplace_back(Unsigned_integer_type e, Unsigned_integer_type m, Unsigned_integer_type &a)
Multiplies the first element with the second one and adds the third one, that is (e * m + a) % 2,...
Definition Z2_field_operators.h:242
static Element add(Unsigned_integer_type e1, Unsigned_integer_type e2)
Returns the sum of two elements in the field.
Definition Z2_field_operators.h:77
static Element multiply(Unsigned_integer_type e1, Unsigned_integer_type e2)
Returns the multiplication of two elements in the field.
Definition Z2_field_operators.h:167
static constexpr Element get_partial_multiplicative_identity(Characteristic productOfCharacteristics)
For interface purposes with multi-fields. Returns the multiplicative identity of the field.
Definition Z2_field_operators.h:380
unsigned int Characteristic
Definition Z2_field_operators.h:35
static void multiply_and_add_inplace_front(Unsigned_integer_type &e, Unsigned_integer_type m, Unsigned_integer_type a)
Multiplies the first element with the second one and adds the third one, that is (e * m + a) % 2,...
Definition Z2_field_operators.h:223
static bool are_equal(Unsigned_integer_type e1, Unsigned_integer_type e2)
Returns true if the two given elements are equal in the field, false otherwise.
Definition Z2_field_operators.h:319
static Element add_and_multiply(Unsigned_integer_type e, Unsigned_integer_type a, Unsigned_integer_type m)
Adds the first element to the second one and multiplies the third one with it. Returns the result in ...
Definition Z2_field_operators.h:262
static void add_and_multiply_inplace_front(Unsigned_integer_type &e, Unsigned_integer_type a, Unsigned_integer_type m)
Adds the first element to the second one and multiplies the third one with it, that is ((e + a) * m) ...
Definition Z2_field_operators.h:281
bool Element
Definition Z2_field_operators.h:34
static void multiply_inplace(Unsigned_integer_type &e1, Unsigned_integer_type e2)
Stores in the first element the multiplication of two given elements in the field,...
Definition Z2_field_operators.h:185
static Element get_inverse(Unsigned_integer_type e)
Returns the inverse of the given element in the field.
Definition Z2_field_operators.h:336
Field namespace.
Definition Intro_field_elements_and_operators.h:16
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14