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

Element of a field of prime characteristic. More...

#include <fields.hpp>

Public Member Functions

Construction
 Prime_Field_Element (Prime_Field *field)
 Constructs a prime field element in the specified field, with the value 0. More...
 
 Prime_Field_Element (COEF_TYPE value, Prime_Field *field)
 Constructs a prime field element in the specified field, with the specified value. More...
 
Basic properties

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

COEF_TYPE value () const
 The value of the element. This always satisfies \(0\leq a\leq m\).
 
unsigned modulus () const
 The field's modulus.
 
Prime_Fieldfield () const
 The field this element lies in.
 
bool like (const Prime_Field_Element &b) const
 true iff this and b have the same modulus.
 
COEF_TYPE inverse () const
 Returns the multiplicative inverse of this.
 
bool is_zero () const
 Is this the additive identity?
 
bool is_one () const
 Is this the multiplicative identity?
 
Modification
void assign (COEF_TYPE val, Prime_Field *K)
 for initializing arrays of Prime_Field_Element
 
Computation

Computes something, and may modify this.

void negate ()
 “Negates” this.
 
void operator+= (const Prime_Field_Element &other)
 
void operator-= (const Prime_Field_Element &other)
 Decreases the value of this.
 
void operator*= (const Prime_Field_Element &other)
 Changes the value of this.
 
void operator*= (const COEF_TYPE b)
 Changes the value of this. This function is useful for avoiding the construction of a prime field element when you know what you want to multiply.
 
void operator/= (const Prime_Field_Element &other)
 Changes the value of this. Multiplies by multiplicative inverse of other.
 

Protected Attributes

COEF_TYPE a
 the number’s value; descendants should ensure \(0\leq a<m\)
 
Prime_FieldF
 the field this element lives in; used to find inverses
 
unsigned m
 the number’ modulus, stored here to avoid the expense of accessing it in \(F\).
 

Friends

Friend functions for computation

Will not modify this.

Prime_Field_Element operator+ (const Prime_Field_Element &, const Prime_Field_Element &)
 Does not modify this. More...
 
Prime_Field_Element operator- (const Prime_Field_Element &, const Prime_Field_Element &)
 Does not modify this. More...
 
Prime_Field_Element operator* (const Prime_Field_Element &, const Prime_Field_Element &)
 Does not modify this. More...
 
Prime_Field_Element operator+ (const Prime_Field_Element &, const int)
 Does not modify this.
 
Prime_Field_Element operator- (const Prime_Field_Element &, const int)
 Does not modify this.
 
Prime_Field_Element operator* (const Prime_Field_Element &, const int)
 Does not modify this.
 
Prime_Field_Element operator- (const Prime_Field_Element &)
 Does not modify this. If you want to modify this, see negate().
 
I/O

Will not modify this.

ostream & operator<< (ostream &, const Prime_Field_Element &)
 

Detailed Description

Element of a field of prime characteristic.

Author
John Perry
Date
2015

This class encapsulates an element of a field of prime characteristic (Prime_Field).

Warning
Do not delete the prime field that this lives in while this is still active. Behavior is unpredictable in this circumstance, as the field is necessary for some record keeping, e.g., to look up multiplicative inverses.
Examples:
test_4by4.cpp, and test_cyclic4.cpp.

Definition at line 118 of file fields.hpp.

Constructor & Destructor Documentation

◆ Prime_Field_Element() [1/2]

Prime_Field_Element::Prime_Field_Element ( Prime_Field field)

Constructs a prime field element in the specified field, with the value 0.

A pointer to field is attached to this in order to find inverses during arithmetic.

Warning
Do not delete this field while this is still active. Behavior is unpredictable in this circumstance.

Definition at line 45 of file fields.cpp.

◆ Prime_Field_Element() [2/2]

Prime_Field_Element::Prime_Field_Element ( COEF_TYPE  value,
Prime_Field field 
)

Constructs a prime field element in the specified field, with the specified value.

A pointer to field is attached to this in order to find inverses during arithmetic.

Warning
Do not delete this field while this is still active. Behavior is unpredictable in this circumstance.

Definition at line 49 of file fields.cpp.

Member Function Documentation

◆ operator+=()

void Prime_Field_Element::operator+= ( const Prime_Field_Element other)

Increases the value of this.

Definition at line 74 of file fields.cpp.

Friends And Related Function Documentation

◆ operator*

Prime_Field_Element operator* ( const Prime_Field_Element a,
const Prime_Field_Element b 
)
friend

Does not modify this.

Assume the terms have the same modulus. Behavior undefined if not!

Definition at line 120 of file fields.cpp.

◆ operator+

Prime_Field_Element operator+ ( const Prime_Field_Element a,
const Prime_Field_Element b 
)
friend

Does not modify this.

Assume the terms have the same modulus. Behavior undefined if not!

Definition at line 100 of file fields.cpp.

◆ operator-

Prime_Field_Element operator- ( const Prime_Field_Element a,
const Prime_Field_Element b 
)
friend

Does not modify this.

Assume the terms have the same modulus. Behavior undefined if not!

Definition at line 110 of file fields.cpp.


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