11#ifndef PERSISTENT_COHOMOLOGY_FIELD_ZP_H_
12#define PERSISTENT_COHOMOLOGY_FIELD_ZP_H_
20namespace persistent_cohomology {
36 void init(
int charac) {
41 throw std::invalid_argument(
"Maximum homology_coeff_field allowed value is 46337");
45 throw std::invalid_argument(
"homology_coeff_field must be a prime number");
48 inverse_.reserve(charac);
49 inverse_.push_back(0);
50 for (
int i = 1; i < Prime; ++i) {
53 while ( (mult % Prime) != 1) {
56 throw std::invalid_argument(
"homology_coeff_field must be a prime number");
59 inverse_.push_back(inv);
66 Element result = (x + w * y) % Prime;
79 Element plus_equal(
const Element& x,
const Element& y) {
93 return std::pair<Element, Element>(inverse_[x], P);
100 return (out < 0) ? out + Prime : out;
111 std::vector<Element> inverse_;
Structure representing the coefficient field .
Definition: Field_Zp.h:27
Element times_minus(Element x, Element y)
Definition: Field_Zp.h:97
Element plus_times_equal(const Element &x, const Element &y, const Element &w)
Definition: Field_Zp.h:64
Element additive_identity() const
Returns the additive idendity of the field.
Definition: Field_Zp.h:84
std::pair< Element, Element > inverse(Element x, Element P)
Definition: Field_Zp.h:92
Element multiplicative_identity(Element=0) const
Returns the multiplicative identity of the field.
Definition: Field_Zp.h:88
Element times(const Element &y, const Element &w)
Definition: Field_Zp.h:75
int characteristic() const
Returns the characteristic of the field.
Definition: Field_Zp.h:104
unspecified Element
Type of element of the field.
Definition: CoefficientField.h:19