23 #ifndef SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_FIELD_ZP_H_
24 #define SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_FIELD_ZP_H_
31 namespace persistent_cohomology {
49 void init(uint16_t charac) {
53 inverse_.reserve(charac);
54 inverse_.push_back(0);
55 for (
int i = 1; i < Prime; ++i) {
57 while (((inv * i) % Prime) != 1)
59 inverse_.push_back(inv);
66 Element result = (x + w * y) % Prime;
75 Element
times(
const Element& y,
const Element& w) {
79 void clear_coefficient(Element x) {
82 Element plus_equal(
const Element& x,
const Element& y) {
95 std::pair<Element, Element>
inverse(Element x, Element P) {
96 return std::pair<Element, Element>(inverse_[x], P);
102 Element out = (-x * y) % Prime;
103 return (out < 0) ? out + Prime : out;
114 std::vector<Element> inverse_;
115 const Element mult_id_all;
116 const Element add_id_all;
123 #endif // SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_FIELD_ZP_H_
std::pair< Element, Element > inverse(Element x, Element P)
Definition: Field_Zp.h:95
Element times(const Element &y, const Element &w)
Definition: Field_Zp.h:75
Structure representing the coefficient field .
Definition: Field_Zp.h:38
const Element & additive_identity() const
Returns the additive idendity of the field.
Definition: Field_Zp.h:87
Element times_minus(Element x, Element y)
Definition: Field_Zp.h:100
const Element & multiplicative_identity(Element P=0) const
Returns the multiplicative identity of the field.
Definition: Field_Zp.h:91
const uint16_t & characteristic() const
Returns the characteristic of the field.
Definition: Field_Zp.h:107
Element plus_times_equal(const Element &x, const Element &y, const Element &w)
Definition: Field_Zp.h:64