17 #ifndef MATRIX_FIELD_Z2_OPERATORS_H_
18 #define MATRIX_FIELD_Z2_OPERATORS_H_
23 namespace persistence_fields {
37 using isUnsignedInteger = std::enable_if_t<std::is_unsigned_v<T> >;
39 using isInteger = std::enable_if_t<std::is_integral_v<T> >;
61 template <
typename Integer_type,
class = isInteger<Integer_type> >
63 if constexpr (std::is_same_v<Integer_type, bool>) {
66 return e < 2 && e >= 0 ? e : e % 2;
78 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
80 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
95 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
96 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> >
114 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
129 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
131 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
145 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
147 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
162 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
164 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
179 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
181 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
197 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
199 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
200 return (e && m) != a;
215 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
217 Unsigned_integer_type m,
218 Unsigned_integer_type a) {
219 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
235 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
237 Unsigned_integer_type m,
238 Unsigned_integer_type& a) {
239 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
256 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
258 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
259 return (e != a) && m;
274 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
276 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
291 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
293 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
309 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
310 static bool are_equal(Unsigned_integer_type e1, Unsigned_integer_type e2) {
311 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
325 template <
typename Un
signed_
integer_type,
class = isUn
signedInteger<Un
signed_
integer_type> >
327 if constexpr (std::is_same_v<Unsigned_integer_type, bool>) {
341 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:96
bool element_type
Definition: Z2_field_operators.h:34
static void substract_inplace_front(Unsigned_integer_type &e1, Unsigned_integer_type e2)
Stores in the first element the substraction in the field of the first element by the second element,...
Definition: Z2_field_operators.h:130
static element_type 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:198
static void substract_inplace_back(Unsigned_integer_type e1, Unsigned_integer_type &e2)
Stores in the second element the substraction in the field of the first element by the second element...
Definition: Z2_field_operators.h:146
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:292
static element_type substract(Unsigned_integer_type e1, Unsigned_integer_type e2)
Returns the substraction in the field of the first element by the second element.
Definition: Z2_field_operators.h:113
static element_type multiply(Unsigned_integer_type e1, Unsigned_integer_type e2)
Returns the multiplication of two elements in the field.
Definition: Z2_field_operators.h:163
static constexpr element_type get_partial_multiplicative_identity([[maybe_unused]] characteristic_type productOfCharacteristics)
For interface purposes with multi-fields. Returns the multiplicative identity of the field.
Definition: Z2_field_operators.h:365
static constexpr element_type get_multiplicative_identity()
Returns the multiplicative identity of the field.
Definition: Z2_field_operators.h:358
static element_type add(Unsigned_integer_type e1, Unsigned_integer_type e2)
Returns the sum of two elements in the field.
Definition: Z2_field_operators.h:79
static element_type 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:257
static element_type get_inverse(Unsigned_integer_type e)
Returns the inverse of the given element in the field.
Definition: Z2_field_operators.h:326
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:236
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:216
static constexpr characteristic_type get_characteristic()
Returns the characteristic of the field, that is 2.
Definition: Z2_field_operators.h:51
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:310
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:275
unsigned int characteristic_type
Definition: Z2_field_operators.h:35
static constexpr element_type get_additive_identity()
Returns the additive identity of the field.
Definition: Z2_field_operators.h:352
static std::pair< element_type, characteristic_type > get_partial_inverse(Unsigned_integer_type e, characteristic_type productOfCharacteristics)
For interface purposes with multi-fields. Returns the inverse together with the second argument.
Definition: Z2_field_operators.h:342
static element_type 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:62
Z2_field_operators()
Default constructor.
Definition: Z2_field_operators.h:44
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:180
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14