Gröbner basis project
Codebase for research into Gröbner basis computation
Prime_Field Class Reference

Information necessary for a field modulo a prime. More...

#include <fields.hpp>

Public Member Functions

Construction
 Prime_Field (unsigned modulus, bool show_modulus=false)
 Please read detailed information. More...
 
 Prime_Field (const Prime_Field &F)
 Copy constructor: copies previously-computed inverses. More...
 
Destruction
 ~Prime_Field ()
 
Basic properties

The following functions give information about the prime field, but do not modify it.

unsigned modulus () const
 Returns the field's modulus.
 
COEF_TYPE inverse (COEF_TYPE a)
 Returns the inverse of \(a\), modulo \(m\). More...
 
Prime_Field_Element unity ()
 “unity” is the multiplicative identity.
 
Prime_Field_Element zero ()
 “zero” is the additive identity.
 
I/O
void set_print_modulus (bool b)
 determines whether to print the modulus
 
bool get_print_modulus ()
 indicates whether to print the modulus
 

Protected Attributes

COEF_TYPE * Fi
 for \(i\neq0\), \(Fi_i\) is multiplicative inverse of \(i\), mod \(m\)
 
unsigned m
 characteristic/modulus of the field
 
bool print_modulus
 determines whether a coefficient's modulus is printed
 

Detailed Description

Information necessary for a field modulo a prime.

Author
John Perry
Date
2015

This class encapsulates the information necessary for a field modulo a prime: both the modulus \(m\) and a list of inverses of non-zero elements. The constructors do not verify that \(m\) is prime, but expect misbehavior if not.

Warning
The constructor does not check whether the supplied modulus is prime. If \(m\) is not prime, behavior is undefined, and probably spectacularly bad.
Examples:
test_4by4.cpp, test_cyclic4.cpp, test_cyclicn.cpp, and test_monomials.cpp.

Definition at line 32 of file fields.hpp.

Constructor & Destructor Documentation

◆ Prime_Field() [1/2]

Prime_Field::Prime_Field ( unsigned  modulus,
bool  show_modulus = false 
)

Please read detailed information.

Parameters
modulusAll computation in this field is done modulo this number; it should be prime, but we do not check this. See this warning.
show_modulusindicates whether the modulus is shown when printing an element of this field. You probably don't want this.
Warning
This constructor does not check whether modulus is prime. If \(m\) is not prime, behavior is undefined, and probably spectacularly bad.

Definition at line 6 of file fields.cpp.

◆ Prime_Field() [2/2]

Prime_Field::Prime_Field ( const Prime_Field F)

Copy constructor: copies previously-computed inverses.

Allocates new data, so you can discard F later if you want.

Definition at line 13 of file fields.cpp.

Member Function Documentation

◆ inverse()

COEF_TYPE Prime_Field::inverse ( COEF_TYPE  a)

Returns the inverse of \(a\), modulo \(m\).

Looks up the inverse in a table. If the inverse is not yet known, this function computes it using the Extended Euclidean Algorithm.

Definition at line 23 of file fields.cpp.


The documentation for this class was generated from the following files: