5 using std::domain_error;
23 template<
typename T, T p>
62 template <
typename T, T p>
68 for (T i = 2; i < p - 1; ++i) {
70 T d = gcd<T>(i, p, a, b);
72 throw domain_error(
"Attempted a non-prime modulus for Modp");
79 template <
typename T, T p>
82 template <
typename T, T p>
88 template <
typename T, T p>
94 template <
typename T, T p>
100 template <
typename T, T p>
106 template <
typename T, T p>
117 template <
typename T, T p>
124 template <
typename T, T p>
133 template<
typename T, T p>
virtual Modp< T, p > & operator*(const T &other) const override
multiplication of value with element of base type
Definition: modp.hpp:101
a field is an integral domain whose nonzero elements have inverses
Definition: rings.hpp:63
virtual bool is_zero() const override
True iff assigned value is congruent to 0
Definition: mod.hpp:104
Definition: integer.hpp:6
virtual Modp< T, p > & inverse() const override
multiplicative inverse
Definition: modp.hpp:118
Modp()
initializes to zero
Definition: modp.hpp:80
bool invertible
whether the element is invertible
Definition: mod.hpp:31
virtual void check_inverse() noexcept override
redefines Mod’s check_inverse() to do nothing
Definition: modp.hpp:35
constexpr Modp< T, p > initialize_inverses
used to force an initialization of inverses at compilation
Definition: modp.hpp:134
virtual bool has_inverse() const override
fields are integral domains where nonzero elements have inverses
Definition: rings.hpp:68
virtual bool has_inverse() const override
fields are integral domains where nonzero elements have inverses
Definition: modp.hpp:125
templated modular arithmetic, modulo a prime
Definition: modp.hpp:24
virtual Modp< T, p > & operator/(const Field_Element &other) const override
division: other element should be of same type, use a cast
Definition: modp.hpp:107
static vector< T > inverses
lists inverses for all nonzero elements
Definition: modp.hpp:32
templated modular arithmetic, making no assumption about the modulus
Definition: mod.hpp:25
void adjust_value()
ensures value is at least 0 but less than modulus
Definition: mod.hpp:34
void check_inverses()
checks whether inverse are set up, and if not sets them up
Definition: modp.hpp:63
T value
value of the element
Definition: mod.hpp:29