11 #ifndef PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ 12 #define PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ 19 namespace persistent_cohomology {
35 void init(
int charac) {
39 inverse_.reserve(charac);
40 inverse_.push_back(0);
41 for (
int i = 1; i < Prime; ++i) {
43 while (((inv * i) % Prime) != 1)
45 inverse_.push_back(inv);
52 Element result = (x + w * y) % Prime;
61 Element
times(
const Element& y,
const Element& w) {
65 Element plus_equal(
const Element& x,
const Element& y) {
78 std::pair<Element, Element>
inverse(Element x, Element P) {
79 return std::pair<Element, Element>(inverse_[x], P);
85 Element out = (-x * y) % Prime;
86 return (out < 0) ? out + Prime : out;
97 std::vector<Element> inverse_;
104 #endif // PERSISTENT_COHOMOLOGY_FIELD_ZP_H_ int characteristic() const
Returns the characteristic of the field.
Definition: Field_Zp.h:90
Element additive_identity() const
Returns the additive idendity of the field.
Definition: Field_Zp.h:70
std::pair< Element, Element > inverse(Element x, Element P)
Definition: Field_Zp.h:78
Element times(const Element &y, const Element &w)
Definition: Field_Zp.h:61
Definition: SimplicialComplexForAlpha.h:14
Structure representing the coefficient field .
Definition: Field_Zp.h:26
Element times_minus(Element x, Element y)
Definition: Field_Zp.h:83
Element multiplicative_identity(Element=0) const
Returns the multiplicative identity of the field.
Definition: Field_Zp.h:74
Element plus_times_equal(const Element &x, const Element &y, const Element &w)
Definition: Field_Zp.h:50