17#ifndef MATRIX_FIELD_Z2_H_
18#define MATRIX_FIELD_Z2_H_
23namespace persistence_fields {
36 using isInteger = std::enable_if_t<std::is_integral_v<T> >;
48 template <
typename Integer_type,
class = isInteger<Integer_type> >
67 f1.element_ = (f1.element_ != f2.element_);
81 template <
typename Integer_type,
class = isInteger<Integer_type> >
88 template <
typename Integer_type,
class = isInteger<Integer_type> >
98 template <
typename Integer_type,
class = isInteger<Integer_type> >
100 return f.element_ != _get_value(v);
107 f1.element_ = (f1.element_ != f2.element_);
121 template <
typename Integer_type,
class = isInteger<Integer_type> >
128 template <
typename Integer_type,
class = isInteger<Integer_type> >
138 template <
typename Integer_type,
class = isInteger<Integer_type> >
140 return f.element_ != _get_value(v);
147 f1.element_ = (f1.element_ && f2.element_);
161 template <
typename Integer_type,
class = isInteger<Integer_type> >
168 template <
typename Integer_type,
class = isInteger<Integer_type> >
178 template <
typename Integer_type,
class = isInteger<Integer_type> >
180 return f.element_ && _get_value(v);
192 template <
typename Integer_type,
class = isInteger<Integer_type> >
194 return _get_value(v) == f.element_;
201 template <
typename Integer_type,
class = isInteger<Integer_type> >
203 return _get_value(v) == f.element_;
214 template <
typename Integer_type,
class = isInteger<Integer_type> >
223 template <
typename Integer_type,
class = isInteger<Integer_type> >
244 operator unsigned int()
const;
258 std::pair<Z2_field_element, unsigned int>
get_partial_inverse(
unsigned int productOfCharacteristics)
const;
298 template <
typename Integer_type,
class = isInteger<Integer_type> >
299 static constexpr Element _get_value(Integer_type e) {
300 if constexpr (std::is_same_v<Integer_type, bool>) {
303 return e < 2 && e >= 0 ? e : e % 2;
310template <
typename Integer_type,
class>
316 : element_(std::exchange(toMove.element_, 0)) {}
319 std::swap(element_, other.element_);
324 element_ = _get_value(value);
328inline Z2_field_element::operator
unsigned int()
const {
return element_; }
335 unsigned int productOfCharacteristics)
const {
344 [[maybe_unused]]
unsigned int productOfCharacteristics) {
Class representing an element of the field.
Definition: Z2_field.h:32
friend Z2_field_element operator-(Z2_field_element f1, Z2_field_element const &f2)
operator-
Definition: Z2_field.h:112
friend Z2_field_element operator+(Z2_field_element f1, Z2_field_element const &f2)
operator+
Definition: Z2_field.h:72
friend Integer_type operator*(const Integer_type &v, Z2_field_element const &f)
operator*
Definition: Z2_field.h:179
friend void operator+=(Z2_field_element &f1, Z2_field_element const &f2)
operator+=
Definition: Z2_field.h:66
std::pair< Z2_field_element, unsigned int > get_partial_inverse(unsigned int productOfCharacteristics) const
For interface purposes with multi-fields. Returns the inverse together with the second argument.
Definition: Z2_field.h:334
friend Z2_field_element operator-(Z2_field_element f, const Integer_type &v)
operator-
Definition: Z2_field.h:129
static constexpr unsigned int get_characteristic()
Returns the characteristic of the field, that is 2.
Definition: Z2_field.h:348
static Z2_field_element get_additive_identity()
Returns the additive identity of the field.
Definition: Z2_field.h:339
friend void swap(Z2_field_element &f1, Z2_field_element &f2)
Swap operator.
Definition: Z2_field.h:239
static Z2_field_element get_multiplicative_identity()
Returns the multiplicative identity of the field.
Definition: Z2_field.h:341
friend void operator+=(Z2_field_element &f, const Integer_type &v)
operator+=
Definition: Z2_field.h:82
friend bool operator==(const Z2_field_element &f, const Integer_type &v)
operator==
Definition: Z2_field.h:202
friend Integer_type operator+(const Integer_type &v, const Z2_field_element &f)
operator+
Definition: Z2_field.h:99
friend Integer_type operator-(const Integer_type v, Z2_field_element const &f)
operator-
Definition: Z2_field.h:139
friend void operator-=(Z2_field_element &f1, Z2_field_element const &f2)
operator-=
Definition: Z2_field.h:106
friend bool operator!=(const Integer_type v, const Z2_field_element &f)
operator!=
Definition: Z2_field.h:215
Z2_field_element get_inverse() const
Returns the inverse of the element.
Definition: Z2_field.h:330
Z2_field_element()
Default constructor.
Definition: Z2_field.h:308
friend Z2_field_element operator*(Z2_field_element f1, Z2_field_element const &f2)
operator*
Definition: Z2_field.h:152
friend bool operator==(const Z2_field_element &f1, const Z2_field_element &f2)
operator==
Definition: Z2_field.h:186
friend bool operator==(const Integer_type &v, const Z2_field_element &f)
operator==
Definition: Z2_field.h:193
friend Z2_field_element operator+(Z2_field_element f, const Integer_type &v)
operator+
Definition: Z2_field.h:89
friend void operator*=(Z2_field_element &f1, Z2_field_element const &f2)
operator*=
Definition: Z2_field.h:146
friend Z2_field_element operator*(Z2_field_element f, const Integer_type &v)
operator*
Definition: Z2_field.h:169
static Z2_field_element get_partial_multiplicative_identity(unsigned int productOfCharacteristics)
For interface purposes with multi-fields. Returns the multiplicative identity of the field.
Definition: Z2_field.h:343
Z2_field_element & operator=(Z2_field_element other)
Assign operator.
Definition: Z2_field.h:318
friend void operator*=(Z2_field_element &f, const Integer_type &v)
operator*=
Definition: Z2_field.h:162
friend void operator-=(Z2_field_element &f, const Integer_type &v)
operator-=
Definition: Z2_field.h:122
Element get_value() const
Returns the value of the element.
Definition: Z2_field.h:350
friend bool operator!=(const Z2_field_element &f1, const Z2_field_element &f2)
operator!=
Definition: Z2_field.h:208
bool Element
Definition: Z2_field.h:34
friend bool operator!=(const Z2_field_element &f, const Integer_type v)
operator!=
Definition: Z2_field.h:224
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14