OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
F4::Monomial Class Reference

Represent a monomial. More...

#include <monomial.h>

Public Member Functions

 Monomial ()
 Constructor. Beware, varlist is not allocated.
 
 Monomial (Monomial const &toCopy)
 Copy constructor.
 
short getDegree () const
 Get the degree of this. More...
 
uint8_t const * getVarlist () const
 Get the varlist of this. More...
 
uint8_t getVarlist (int index) const
 Get varlist[index]. More...
 
void setVarlist (uint8_t *varlist)
 Set the varlist of this.
 
void allocate ()
 Allocate the varlist of this.
 
void erase ()
 Delete the varlist of this.
 
void setMonomial (uint8_t const *varlist)
 Initialize this with varlist. More...
 
void setMonomial (std::string const s)
 Initialize this with s. More...
 
void setMonomial (int numMon)
 Initialize this with the numMon th monomial. More...
 
void setMonomial (Monomial const &mon)
 Initialize this with mon. More...
 
void setMonomialMultiply (Monomial const &mon1, Monomial const &mon2)
 Initialize this with mon1 * mon2. More...
 
void setMonomialDivide (Monomial const &mon1, Monomial const &mon2)
 Initialize this with mon1 / mon2. More...
 
void intToMonomial (int numMon)
 Initialize this with the num-th monomial. More...
 
int monomialToInt () const
 Compute the number of this. More...
 
void printMonomial (std::ostream &stream) const
 Print the monomial. More...
 
int compareMonomial (Monomial const &mon) const
 Compare monomials according to the grevlex order. More...
 
bool isDivisible (Monomial const &mon) const
 Test if this is divisible by mon. More...
 
void reset ()
 Reset this. More...
 
Monomialoperator= (Monomial const &mon)
 Overload the operator =. More...
 
Monomialoperator= (Monomial &&mon)
 Overload the operator = (move assignment). Used when mon is unnamed (only copy the pointer). More...
 
Monomialoperator*= (Monomial const &mon)
 Overload the operator *=. More...
 
Monomialoperator/= (Monomial const &mon)
 Overload the operator /=. More...
 

Static Public Member Functions

static void setNbVariable (int nbVariable)
 Modify the static variable NB_VARIABLE. More...
 
static int getNbVariable ()
 Get the static variable NB_VARIABLE. More...
 
static void setVariable (std::string const *vars)
 Modify the static variable VARS. More...
 
static std::string const * getVariable ()
 Get the static variable VARS. More...
 
static void setWeight (int *weight)
 Modify the static variable WEIGHT. More...
 
static int * getWeight ()
 Get the static variable WEIGHT. More...
 
static short getMaxDegree ()
 Get the static variable MAX_DEGREE. More...
 
static void setNbMonomial (short maxDegree)
 Modify the dynamic 2D array NB_MONOMIAL, and call setMonomialArray(). More...
 
static void increaseNbMonomial (int numMonomial)
 Modify the dynamic 2D array NB_MONOMIAL. More...
 
static int getNbMonomial ()
 Get NB_MONOMIAL[MAX_DEGREE][NB_VARIABLE+1]. More...
 
static int getNbMonomial (int row, int column)
 Get NB_MONOMIAL[row][column]. More...
 
static void freeNbMonomial ()
 Free the dynamic 2D array NB_MONOMIAL, and call freeMonomialArray(). More...
 
static int compareNumMonomial (int numMon1, int numMon2)
 Compare two monomials, using MONOMIAL_ARRAY if possible. More...
 
static int varlistToInt (uint8_t const *varlist)
 Compute the number of a monomial from its varlist. More...
 
static int varlistToInt (uint8_t const *varlist, short deg)
 Compute the number of a monomial from its varlist and its degree. More...
 
static int varlistToInt (uint8_t const *varlist1, uint8_t const *varlist2)
 Compute the number of a product of 2 monomials from their varlists. More...
 
static void initMonomial (int nbVariable, short degree=1)
 Initialise the static parameters of Monomial. More...
 
static void freeMonomial ()
 Free the space allocated by initMonomial.
 

Private Attributes

short _deg
 
uint8_t * _varlist
 

Static Private Attributes

static int NB_VARIABLE
 
static std::string const * VARS
 
static int * WEIGHT
 
static std::vector< int * > NB_MONOMIAL
 NB_MONOMIAL[d][v] = Number of degree d monomials in the v first variables. NB_MONOMIAL[d][NB_VARIABLE+1] = Number of monomials of degree <= d.
 
static short MAX_DEGREE
 

Friends

int multiplyMonomial (Monomial const &mon1, Monomial const &mon2)
 Multiply mon1 and mon2. More...
 

Detailed Description

Represent a monomial.

Definition at line 46 of file monomial.h.

Member Function Documentation

int F4::Monomial::compareMonomial ( Monomial const &  mon) const

Compare monomials according to the grevlex order.

Precondition
The static variable NB_VARIABLE must be set beforehand.
Parameters
monMonomial.
Returns
0 if this==mon.
1 if this>mon.
-1 if this<mon.
static int F4::Monomial::compareNumMonomial ( int  numMon1,
int  numMon2 
)
static

Compare two monomials, using MONOMIAL_ARRAY if possible.

Parameters
numMon1Number of the first monomial.
numMon2Number of the second monomial.
Returns
0 if numMon1==numMon2.
1 if numMon1>numMon2.
-1 if numMon1<numMon2.
static void F4::Monomial::freeNbMonomial ( )
static

Free the dynamic 2D array NB_MONOMIAL, and call freeMonomialArray().

Parameters
maxDegreeMaximal degree (height) of NB_MONOMIAL.
short F4::Monomial::getDegree ( ) const

Get the degree of this.

Returns
Degree of this.
static short F4::Monomial::getMaxDegree ( )
static

Get the static variable MAX_DEGREE.

Returns
Value of MAX_DEGREE.
static int F4::Monomial::getNbMonomial ( )
static

Get NB_MONOMIAL[MAX_DEGREE][NB_VARIABLE+1].

Returns
Number of monomials of degree less than MAX_DEGREE.
static int F4::Monomial::getNbMonomial ( int  row,
int  column 
)
static

Get NB_MONOMIAL[row][column].

Parameters
rowIndex of the row.
columnIndex of the column.
Returns
NB_MONOMIAL[row][column].
static int F4::Monomial::getNbVariable ( )
static

Get the static variable NB_VARIABLE.

Returns
Value of NB_VARIABLE.
static std::string const* F4::Monomial::getVariable ( )
static

Get the static variable VARS.

Returns
Value of VARS.
uint8_t const* F4::Monomial::getVarlist ( ) const

Get the varlist of this.

Returns
Varlist of this.
uint8_t F4::Monomial::getVarlist ( int  index) const

Get varlist[index].

Returns
varlist[index].
static int* F4::Monomial::getWeight ( )
static

Get the static variable WEIGHT.

Returns
Value of WEIGHT.
static void F4::Monomial::increaseNbMonomial ( int  numMonomial)
static

Modify the dynamic 2D array NB_MONOMIAL.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
Parameters
numMonomialNB_MONOMIAL is set such that numMonomial belongs to it.
static void F4::Monomial::initMonomial ( int  nbVariable,
short  degree = 1 
)
static

Initialise the static parameters of Monomial.

Parameters
nbVariableNumber of variables of the polynomial ring.
degreeInitialise NB_MONOMIAL up to degree "degree".
Examples:
tutorial-big-modulo-method3.cpp, tutorial-gf2-extension-method3.cpp, tutorial-gf2-method3.cpp, and tutorial-method3.cpp.
void F4::Monomial::intToMonomial ( int  numMon)

Initialize this with the num-th monomial.

Precondition
Static variables NB_VARIABLE, WEIGHT and NB_MONOMIAL must be set beforehand.
Parameters
numMonnumber of the constructed monomial, 0 is the smallest monomial.
bool F4::Monomial::isDivisible ( Monomial const &  mon) const

Test if this is divisible by mon.

Precondition
The static variable NB_VARIABLE must be set beforehand.
Parameters
monDivisor.
Returns
true if mon divides this.
false otherwise.
int F4::Monomial::monomialToInt ( ) const

Compute the number of this.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
Returns
Number of this.
Monomial& F4::Monomial::operator*= ( Monomial const &  mon)

Overload the operator *=.

Precondition
The static variable NB_VARIABLE must be set beforehand.
Parameters
monMonomial.
Returns
Reference on this.
Monomial& F4::Monomial::operator/= ( Monomial const &  mon)

Overload the operator /=.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
this must be divisible by mon.
Parameters
monMonomial (divisor).
Returns
Reference on this.
Monomial& F4::Monomial::operator= ( Monomial const &  mon)

Overload the operator =.

Precondition
The static variable NB_VARIABLE must be set beforehand.
Parameters
monMonomial to copy.
Returns
Reference on this.
Monomial& F4::Monomial::operator= ( Monomial &&  mon)

Overload the operator = (move assignment). Used when mon is unnamed (only copy the pointer).

Precondition
The static variable NB_VARIABLE must be set beforehand.
Parameters
monMonomial to copy.
Returns
Reference on this.
void F4::Monomial::printMonomial ( std::ostream &  stream) const

Print the monomial.

Precondition
The static variable NB_VARIABLE must be set beforehand.
void F4::Monomial::reset ( )

Reset this.

Precondition
The static variable NB_VARIABLE must be set beforehand.
void F4::Monomial::setMonomial ( uint8_t const *  varlist)

Initialize this with varlist.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
Parameters
varlistArray representing the degree of each variable of the monomial.
void F4::Monomial::setMonomial ( std::string const  s)

Initialize this with s.

Precondition
Static variables NB_VARIABLE, WEIGHT and VARS must be set beforehand.
Parameters
sString representing the monomial.
void F4::Monomial::setMonomial ( int  numMon)

Initialize this with the numMon th monomial.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
Parameters
numMonnumber of the constructed monomial, 0 is the smallest monomial.
void F4::Monomial::setMonomial ( Monomial const &  mon)

Initialize this with mon.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
Parameters
monMonomial.
void F4::Monomial::setMonomialDivide ( Monomial const &  mon1,
Monomial const &  mon2 
)

Initialize this with mon1 / mon2.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
mon1 must be divisible by mon2.
Parameters
mon1Monomial.
mon2Monomial.
void F4::Monomial::setMonomialMultiply ( Monomial const &  mon1,
Monomial const &  mon2 
)

Initialize this with mon1 * mon2.

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
Parameters
mon1Monomial.
mon2Monomial.
static void F4::Monomial::setNbMonomial ( short  maxDegree)
static

Modify the dynamic 2D array NB_MONOMIAL, and call setMonomialArray().

Precondition
Static variables NB_VARIABLE and WEIGHT must be set beforehand.
Parameters
maxDegreeMaximal degree (height) of NB_MONOMIAL.
static void F4::Monomial::setNbVariable ( int  nbVariable)
static

Modify the static variable NB_VARIABLE.

Parameters
nbVariableNumber of variables of the polynomial ring.
static void F4::Monomial::setVariable ( std::string const *  vars)
static

Modify the static variable VARS.

Parameters
varsArray of variable names of the polynomial ring.
Examples:
tutorial-big-modulo-method3.cpp, tutorial-gf2-extension-method3.cpp, tutorial-gf2-method3.cpp, and tutorial-method3.cpp.
static void F4::Monomial::setWeight ( int *  weight)
static

Modify the static variable WEIGHT.

Parameters
weightArray of weights.
static int F4::Monomial::varlistToInt ( uint8_t const *  varlist)
static

Compute the number of a monomial from its varlist.

Parameters
varlistArray representing the degree of each variable of the monomial.
Returns
Number of the corresponding monomial.
static int F4::Monomial::varlistToInt ( uint8_t const *  varlist,
short  deg 
)
static

Compute the number of a monomial from its varlist and its degree.

Precondition
NB_MONOMIAL must be set up to degree deg.
Parameters
varlistArray representing the degree of each variable of the monomial.
degreeDegree of the monomial.
Returns
Number of the corresponding monomial.
static int F4::Monomial::varlistToInt ( uint8_t const *  varlist1,
uint8_t const *  varlist2 
)
static

Compute the number of a product of 2 monomials from their varlists.

Parameters
varlist1Array representing the degree of each variable of the first monomial.
varlist2Array representing the degree of each variable of the second monomial.
Returns
Number of the corresponding monomial.

Friends And Related Function Documentation

int multiplyMonomial ( Monomial const &  mon1,
Monomial const &  mon2 
)
friend

Multiply mon1 and mon2.

Parameters
mon1Monomial.
mon2Monomial.
Returns
Number of mon1 * mon2.

Member Data Documentation

short F4::Monomial::_deg
private

Degree of the monomial

Definition at line 360 of file monomial.h.

uint8_t* F4::Monomial::_varlist
private

Array representing the degree of each variable of the monomial

Definition at line 361 of file monomial.h.

short F4::Monomial::MAX_DEGREE
staticprivate

Maximal degree (height) of NB_MONOMIAL.

Definition at line 371 of file monomial.h.

int F4::Monomial::NB_VARIABLE
staticprivate

Number of variables of the polynomial ring.

Definition at line 363 of file monomial.h.

std::string const* F4::Monomial::VARS
staticprivate

Array of NB_VARIABLE string representing the variable names.

Definition at line 364 of file monomial.h.

int* F4::Monomial::WEIGHT
staticprivate

Array of NB_VARIABLE weights.

Definition at line 365 of file monomial.h.


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