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

Implementation of monomials. More...

#include <monomial.hpp>

Public Member Functions

Construction
void common_initialization (Monomial_Ordering *ord=nullptr)
 things all Monomial initializers must do
 
void initialize_exponents (NVAR_TYPE number_of_vars)
 allocates memory for exponents This is useful when you want to allocate an array of monomials.
 
void deinitialize ()
 deallocates memory for exponents This is useful when you want to deallocate an array of monomials.
 
void set_exponent (NVAR_TYPE i, DEG_TYPE e)
 change \(i\)th exponent to \(e\)
 
 Monomial (NVAR_TYPE number_of_vars, Monomial_Ordering *order=generic_grevlex_ptr)
 The first constructor is equivalent to instantiating 1.
 
 Monomial (const Monomial &other)
 Copy constructor, allocates new space for exponents.
 
 Monomial (initializer_list< EXP_TYPE > powers, Monomial_Ordering *order=generic_grevlex_ptr)
 Constructor from initializer list. More...
 
 Monomial (NVAR_TYPE size, const EXP_TYPE *powers, Monomial_Ordering *order=generic_grevlex_ptr)
 Constructor from array of exponents. More...
 
Destruction
 ~Monomial ()
 Destructor deallocates exponents.
 
Basic properties

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

NVAR_TYPE num_vars () const
 number of variables
 
bool is_one () const
 all exponents 0?
 
DEG_TYPE degree (NVAR_TYPE i) const
 Degree of \(i\)th variable.
 
DEG_TYPE operator[] (NVAR_TYPE i) const
 Degree of \(i\)th variable. Synonymous with degree().
 
DEG_TYPE total_degree (NVAR_TYPE m=0) const
 Sum of exponents of the first \(m\) variables. More...
 
DEG_TYPE weighted_degree (const WT_TYPE *weights, NVAR_TYPE m=0) const
 weighted sum of first \(m\) exponents, using given weights More...
 
const EXP_TYPE * log () const
 Direct access to the exponents, for whatever reason.
 
Comparison

Compares this monomial to another.

Monomial_Orderingmonomial_ordering () const
 the Monomial_Ordering associated with this Monomial
 
Monomial_Order_Datamonomial_ordering_data () const
 the Monomial_Order_Data associated with this Monomial
 
void set_monomial_ordering (Monomial_Ordering *mord)
 sets the Monomial_Ordering associated with this Monomial
 
void set_ordering_data (Monomial_Order_Data *mordat)
 sets the Monomial_Order_Data associated with this Monomial
 
bool operator== (const Monomial &other) const
 equal/alike?
 
bool operator!= (const Monomial &other) const
 unequal/unlike?
 
bool is_coprime (const Monomial &other) const
 true iff this has no common factor with other.
 
int cmp (const Monomial &u) const
 Returns 0 if like, negative if smaller.
 
bool is_like (const Monomial &other) const
 Have same variables, same powers? Synonymous with operator==().
 
bool like_multiple (const Monomial &u, const Monomial &v) const
 is this like \(uv\)?
 
bool like_multiple (EXP_TYPE *e, const Monomial &v) const
 is this like \(uv\)? (where \(u\) is a monomial whose exponents are those of e
 
bool larger_than (const Monomial &) const
 compares monomial with \(u\) according to monomial ordering
 
bool operator> (const Monomial &u) const
 Compares monomial with \(u\) according to monomial ordering.
 
bool operator>= (const Monomial &u) const
 Compares monomial with \(u\) according to monomial ordering.
 
bool operator< (const Monomial &u) const
 Compares monomial with \(u\) according to monomial ordering.
 
bool operator<= (const Monomial &u) const
 Compares monomial with \(u\) according to monomial ordering.
 
bool larger_than_multiple (const Monomial &u, const Monomial &v) const
 Compares monomial with \(uv\) according to monomial ordering.
 
bool divisible_by (const Monomial &other) const
 Divisible by other?
 
bool operator| (const Monomial &other) const
 operator for divisibility
 
Computation

Computes something, and may modify this.

Monomialoperator= (const Monomial &other)
 assignment
 
Monomialoperator*= (const Monomial &other)
 Multiply this by other.
 
Monomial operator* (const Monomial &other) const
 Return result of this by other.
 
bool operator/= (const Monomial &other)
 Divide this by other. More...
 
Monomial lcm (const Monomial &u) const
 Least common multiple: largest exponents.
 
Monomial gcd (const Monomial &u) const
 Greatest common divisor: smallest exponents.
 
Monomial colon (const Monomial &u) const
 colon operator: exponents needed to make \(u\) divisible by this
 
Memory management
void * operator new (size_t)
 requests memory form Monomial's Grading_Order_Data_Allocator
 
void operator delete (void *)
 returns data to Monomial's Grading_Order_Data_Allocator
 

Protected Attributes

EXP_TYPE * exponents
 has size n
 
uint64_t mask
 divisibility mask (up to 64 variables)
 
NVAR_TYPE n
 number of variables
 
Monomial_Orderingordering
 Monomial_Ordering associated with this polynomial.
 
Monomial_Order_Dataordering_data
 optional data for a monomial ordering
 

I/O

void print (bool=true, ostream &=cout, const string *names=nullptr) const
 prints the monomial to the give stream with the given names; adds a newline if the boolean is true
 
void printlncout ()
 equivalent to print() with default values
 
ostream & operator<< (ostream &, const Monomial &u)
 essentially u.print(false, ostream)
 

Detailed Description

Implementation of monomials.

Author
John Perry
Date
2015

A monomial is a product of powers, for instance \(x_1^2x_3\). (We do not include coefficients in our definition of monomials.) This class encapsulates basic monomial functionality necessary for computing Gröbner bases.

Warning
When initializing an array of Monomial , be sure to use the initialization functions to format and allocate space.
Any monomial requires that you specify a number of variables. At the present time, the limit on this is 64 (for the sake of masking; though an earlier verison of the code did not have this limit). Most operations require that the number of variables be the same, but the code does not check for this. For what I am designing this for, this is acceptable, but if you intend to work with monomials that contain a different number of variables, check to make sure that any monomial arithmetic involves monomials with the same number of variables.
Examples:
test_4by4.cpp, test_cyclic4.cpp, and test_monomials.cpp.

Definition at line 52 of file monomial.hpp.

Constructor & Destructor Documentation

◆ Monomial() [1/2]

Monomial::Monomial ( initializer_list< EXP_TYPE >  powers,
Monomial_Ordering order = generic_grevlex_ptr 
)

Constructor from initializer list.

The list should contains the powers of the exponents, in order.

Definition at line 102 of file monomial.cpp.

◆ Monomial() [2/2]

Monomial::Monomial ( NVAR_TYPE  size,
const EXP_TYPE *  powers,
Monomial_Ordering order = generic_grevlex_ptr 
)

Constructor from array of exponents.

Copies exponents so you can reuse yours.

Definition at line 129 of file monomial.cpp.

Member Function Documentation

◆ operator/=()

bool Monomial::operator/= ( const Monomial other)

Divide this by other.

Warning
Does not check if this is divisible by other. See divisible_by(), which is the tool to use.

Definition at line 340 of file monomial.cpp.

◆ total_degree()

DEG_TYPE Monomial::total_degree ( NVAR_TYPE  m = 0) const

Sum of exponents of the first \(m\) variables.

If m is zero (default), computes for all variables.

Definition at line 174 of file monomial.cpp.

◆ weighted_degree()

DEG_TYPE Monomial::weighted_degree ( const WT_TYPE *  weights,
NVAR_TYPE  m = 0 
) const

weighted sum of first \(m\) exponents, using given weights

If weights is nullptr then returns total_degree(m). If m is zero (default), computes for all variables.

Definition at line 183 of file monomial.cpp.


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