|
Macaulay2 Engine
|
Discrete-log Z/p adapter that represents non-zero residues by their exponent index relative to a generator. More...
#include <coeffrings.hpp>
Public Types | |
| typedef Z_mod | ring_type |
| typedef int | elem |
| typedef elem | ElementType |
| typedef std::vector< elem > | ElementContainerType |
Public Member Functions | |
| CoefficientRingZZp (int p0, int *log, int *exps) | |
| void | set_from_long (elem &result, long a) const |
| void | set_from_mpz (elem &result, mpz_t a) const |
| long | coerceToLongInteger (const elem &f) const |
| int | to_int (int f) const |
| void | init (elem &result) const |
| void | init_set (elem &result, elem a) const |
| void | set_zero (elem &result) const |
| void | set (elem &result, elem a) const |
| bool | is_zero (elem result) const |
| bool | is_equal (elem a, elem b) const |
| void | invert (elem &result, elem a) const |
| void | add (elem &result, elem a, elem b) const |
| void | negate (elem &result, elem a) const |
| void | subtract (elem &result, elem a, elem b) const |
| void | subtract_multiple (elem &result, elem a, elem b) const |
| void | mult (elem &result, elem a, elem b) const |
| void | divide (elem &result, elem a, elem b) const |
| void | to_ring_elem (ring_elem &result, const elem a) const |
| void | from_ring_elem (elem &result, const ring_elem &a) const |
| void | swap (elem &a, elem &b) const |
| void | elem_text_out (buffer &o, ElementType a, bool p_one=true, bool p_plus=false, bool p_parens=false) const |
Static Public Member Functions | |
| static void | clear (elem &result) |
| Static Public Member Functions inherited from our_new_delete | |
| static void * | operator new (size_t size) |
| static void * | operator new[] (size_t size) |
| static void | operator delete (void *obj) |
| static void | operator delete[] (void *obj) |
| static void * | operator new (size_t size, void *existing_memory) |
| static void * | operator new[] (size_t size, void *existing_memory) |
| static void | operator delete (void *obj, void *existing_memory) |
| static void | operator delete[] (void *obj, void *existing_memory) |
Static Private Member Functions | |
| static int | modulus_add (int a, int b, int p) |
| static int | modulus_sub (int a, int b, int p) |
Private Attributes | |
| int | p |
| int | p1 |
| int | minus_one |
| int | zero |
| int * | log_table |
| int * | exp_table |
Discrete-log Z/p adapter that represents non-zero residues by their exponent index relative to a generator.
Holds two size-p tables: exp_table maps an index a to the residue g^a mod p and log_table is its inverse. Multiplication and division on indices become modulus_add / modulus_sub mod p - 1 with no table lookup, and inversion of a non-zero index a is p - 1 - a. Addition / subtraction first hop to residues via exp_table, do a modular add/sub, and hop back via log_table. negate shifts by (p - 1) / 2 (the index of -1). Used for small primes (2 <= p <= 32749 per interface/aring.h) via the SimpleARing CRTP layer.
Definition at line 66 of file coeffrings.hpp.