17#ifndef MATRIX_FIELD_Z2_OPERATORS_H_ 
   18#define MATRIX_FIELD_Z2_OPERATORS_H_ 
   23namespace 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> >
 
   79  static Element add(Unsigned_integer_type e1, Unsigned_integer_type e2) {
 
   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> >
 
  343      Unsigned_integer_type e, 
Characteristic productOfCharacteristics) {
 
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
 
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:198
 
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:130
 
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:62
 
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 constexpr Element get_multiplicative_identity()
Returns the multiplicative identity of the field.
Definition: Z2_field_operators.h:358
 
static constexpr Element get_additive_identity()
Returns the additive identity of the field.
Definition: Z2_field_operators.h:352
 
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:342
 
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:51
 
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:146
 
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 Element 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 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 get_partial_multiplicative_identity(Characteristic productOfCharacteristics)
For interface purposes with multi-fields. Returns the multiplicative identity of the field.
Definition: Z2_field_operators.h:365
 
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:216
 
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 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:257
 
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
 
bool Element
Definition: Z2_field_operators.h:34
 
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
 
static Element get_inverse(Unsigned_integer_type e)
Returns the inverse of the given element in the field.
Definition: Z2_field_operators.h:326
 
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14