Frobby  0.9.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Term Class Reference

Term represents a product of variables which does not include a coefficient. More...

#include <Term.h>

Public Member Functions

 Term ()
 
 Term (const Term &term)
 
 Term (const Exponent *exponents, size_t varCount)
 
 Term (size_t varCount)
 This object is initialized to the identity, i.e. the exponent vector is the zero vector. More...
 
 Term (const string &str)
 Accepts a whitespace-separated list of integers as exponent vector. More...
 
 ~Term ()
 
 operator Exponent * ()
 
 operator const Exponent * () const
 
Exponentbegin ()
 
const Exponentbegin () const
 
Exponentend ()
 
const Exponentend () const
 
size_t getVarCount () const
 
Exponent operator[] (int offset) const
 
Exponent operator[] (unsigned int offset) const
 
Exponent operator[] (unsigned long offset) const
 
Exponentoperator[] (int offset)
 
Exponentoperator[] (unsigned int offset)
 
Exponentoperator[] (unsigned long offset)
 
bool operator== (const Term &term) const
 
bool operator== (const Exponent *term) const
 
bool operator!= (const Term &term) const
 
bool operator!= (const Exponent *term) const
 
Termoperator= (const Term &term)
 
Termoperator= (const Exponent *exponents)
 
bool divides (const Term &term) const
 
bool divides (const Exponent *term) const
 
bool dominates (const Term &term) const
 
bool dominates (const Exponent *term) const
 
bool strictlyDivides (const Term &term) const
 
bool strictlyDivides (const Exponent *term) const
 
void lcm (const Term &a, const Term &b, int position)
 
void lcm (const Term &a, const Term &b)
 
void lcm (const Exponent *a, const Exponent *b)
 
void gcd (const Term &a, const Term &b)
 
void gcd (const Exponent *a, const Exponent *b)
 
void product (const Term &a, const Term &b)
 Set this object equal to the product of a and b. More...
 
void product (const Exponent *a, const Exponent *b)
 
void setToIdentity ()
 
bool isIdentity () const
 
bool isSquareFree () const
 
size_t getFirstNonZeroExponent () const
 
size_t getMiddleNonZeroExponent () const
 
size_t getFirstMaxExponent () const
 
size_t getMaxExponent () const
 
size_t getSizeOfSupport () const
 
size_t getHashCode () const
 
bool sharesNonZeroExponent (const Exponent *a) const
 
bool sharesNonZeroExponent (const Term &a) const
 
bool hasSameSupport (const Term &a) const
 
bool hasSameSupport (const Exponent *a) const
 
void colon (const Term &a, const Term &b)
 
void colon (const Exponent *a, const Exponent *b)
 
void encodedDual (const Term &dualOf, const Term &point)
 
void encodedDual (const Exponent *dualOf, const Exponent *point)
 
void decrement ()
 
void swap (Term &term)
 
void reset (size_t newVarCount)
 
void clear ()
 
void print (FILE *file) const
 
void print (ostream &out) const
 

Static Public Member Functions

static bool divides (const Exponent *a, const Exponent *b, size_t varCount)
 Returns whether a divides b. More...
 
static bool dominates (const Exponent *a, const Exponent *b, size_t varCount)
 Returns whether a dominates b, i.e. whether b divides a. More...
 
static bool strictlyDivides (const Exponent *a, const Exponent *b, size_t varCount)
 Returns whether a strictly divides b. More...
 
static void lcm (Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
 Sets res equal to the least commom multiple of a and b. More...
 
static void gcd (Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
 Sets res equal to the greatest common divisor of a and b. More...
 
static void product (Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
 Sets res equal to the product of a and b. More...
 
static void setToIdentity (Exponent *res, size_t varCount)
 Set res equal to $1=x^{(0,\ldots,0)}$, i.e. set each entry of res equal to 0. More...
 
static bool isIdentity (const Exponent *a, size_t varCount)
 Returns whether a is 1, i.e. whether all entries of a are 0. More...
 
static bool isSquareFree (const Exponent *a, size_t varCount)
 Returns whether a is square free, i.e. $v_i\leq 1$ for each $i$ where $a=x^v$. More...
 
static size_t getFirstNonZeroExponent (const Exponent *a, size_t varCount)
 Returns least var such that a[var] is non-zero. More...
 
static size_t getMiddleNonZeroExponent (const Exponent *a, size_t varCount)
 Returns a median element of the set of var's such that a[var] is non-zero. More...
 
static size_t getFirstMaxExponent (const Exponent *a, size_t varCount)
 Returns a var such that a[var] >= a[i] for all i. More...
 
static size_t getSizeOfSupport (const Exponent *a, size_t varCount)
 Returns the number of variables $x_i$ such that $x_i$ divides $a$. More...
 
static bool sharesNonZeroExponent (const Exponent *a, const Exponent *b, size_t varCount)
 Returns whether there is some $i$ such that $a_i=b_i>0$. More...
 
static size_t getHashCode (const Exponent *a, size_t varCount)
 
static bool hasSameSupport (const Exponent *a, const Exponent *b, size_t varCount)
 Returns whether $x_i|a\Leftrightarrow x_i|b$ for every variable $x_i$. More...
 
static void colon (Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
 Sets res equal to $a : b$. More...
 
static void encodedDual (Exponent *res, const Exponent *dualOf, const Exponent *point, size_t varCount)
 The parameter dualOf is interpreted to encode an irreducible ideal, and the dual of that reflected in point is a principal ideal. More...
 
static void decrement (Exponent *a, size_t varCount)
 Decrements each positive entry of a by one. More...
 
static void print (FILE *file, const Exponent *e, size_t varCount)
 Writes e to file in a format suitable for debug output. More...
 
static void print (ostream &out, const Exponent *e, size_t varCount)
 Writes e to out in a format suitable for debug output. More...
 

Private Member Functions

void initialize (const Exponent *exponents, size_t varCount)
 

Static Private Member Functions

static Exponentallocate (size_t size)
 
static void deallocate (Exponent *p, size_t size)
 

Private Attributes

Exponent_exponents
 
size_t _varCount
 

Detailed Description

Term represents a product of variables which does not include a coefficient.

This concept is also sometimes called a monomial or power product.

A term is represented as an array of Exponent and an integer indicating the length of the array, i.e. the number of variables. It is sometimes desirable to separate the length from the array, e.g. when representing an array of terms all of the same length, such as in representing the generators of a monomial ideal, in which case representing the length once for each generator would be wasteful. Thus Term has static versions of most methods where the number of variables is a separate parameter. In these cases it is allowed for the exponent array pointer to be null (i.e. equal to 0) if the length is zero.

Most methods on Term are inline to avoid function call overhead. This is significant because these methods tend to be called in the innermost loops of monomial ideal algorithms.

Todo:
Move the inline code out of the class declaration and add them as inline below the class declaration.
Todo:
Duplicate the comments for overloads using the copydoc Doxygen command.
Todo:
Rename term.h to Term.h.

Definition at line 49 of file Term.h.

Constructor & Destructor Documentation

Term::Term ( )
inline

Definition at line 51 of file Term.h.

Term::Term ( const Term term)
inline

Definition at line 52 of file Term.h.

Term::Term ( const Exponent exponents,
size_t  varCount 
)
inline

Definition at line 53 of file Term.h.

Term::Term ( size_t  varCount)
inline

This object is initialized to the identity, i.e. the exponent vector is the zero vector.

Definition at line 60 of file Term.h.

Term::Term ( const string &  str)

Accepts a whitespace-separated list of integers as exponent vector.

Definition at line 27 of file Term.cpp.

Term::~Term ( )
inline

Definition at line 74 of file Term.h.

Member Function Documentation

Exponent * Term::allocate ( size_t  size)
staticprivate

Definition at line 86 of file Term.cpp.

Exponent* Term::begin ( )
inline

Definition at line 79 of file Term.h.

const Exponent* Term::begin ( ) const
inline

Definition at line 80 of file Term.h.

void Term::clear ( )
inline

Definition at line 554 of file Term.h.

static void Term::colon ( Exponent res,
const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Sets res equal to $a : b$.

$a : b$ is read as "a colon b", and it is defined as $lcm(a, b) / b$.

Definition at line 468 of file Term.h.

void Term::colon ( const Term a,
const Term b 
)
inline

Definition at line 482 of file Term.h.

void Term::colon ( const Exponent a,
const Exponent b 
)
inline

Definition at line 488 of file Term.h.

void Term::deallocate ( Exponent p,
size_t  size 
)
staticprivate

Definition at line 98 of file Term.cpp.

static void Term::decrement ( Exponent a,
size_t  varCount 
)
inlinestatic

Decrements each positive entry of a by one.

Definition at line 524 of file Term.h.

void Term::decrement ( )
inline

Definition at line 531 of file Term.h.

static bool Term::divides ( const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Returns whether a divides b.

Definition at line 144 of file Term.h.

bool Term::divides ( const Term term) const
inline

Definition at line 153 of file Term.h.

bool Term::divides ( const Exponent term) const
inline

Definition at line 158 of file Term.h.

static bool Term::dominates ( const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Returns whether a dominates b, i.e. whether b divides a.

Definition at line 164 of file Term.h.

bool Term::dominates ( const Term term) const
inline

Definition at line 174 of file Term.h.

bool Term::dominates ( const Exponent term) const
inline

Definition at line 179 of file Term.h.

static void Term::encodedDual ( Exponent res,
const Exponent dualOf,
const Exponent point,
size_t  varCount 
)
inlinestatic

The parameter dualOf is interpreted to encode an irreducible ideal, and the dual of that reflected in point is a principal ideal.

The generated of this ideal is written to res. This requires that dualOf divides point, as otherwise that dual is not defined.

Definition at line 497 of file Term.h.

void Term::encodedDual ( const Term dualOf,
const Term point 
)
inline

Definition at line 513 of file Term.h.

void Term::encodedDual ( const Exponent dualOf,
const Exponent point 
)
inline

Definition at line 519 of file Term.h.

Exponent* Term::end ( )
inline

Definition at line 82 of file Term.h.

const Exponent* Term::end ( ) const
inline

Definition at line 83 of file Term.h.

static void Term::gcd ( Exponent res,
const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Sets res equal to the greatest common divisor of a and b.

Definition at line 247 of file Term.h.

void Term::gcd ( const Term a,
const Term b 
)
inline

Definition at line 261 of file Term.h.

void Term::gcd ( const Exponent a,
const Exponent b 
)
inline

Definition at line 267 of file Term.h.

static size_t Term::getFirstMaxExponent ( const Exponent a,
size_t  varCount 
)
inlinestatic

Returns a var such that a[var] >= a[i] for all i.

Definition at line 373 of file Term.h.

size_t Term::getFirstMaxExponent ( ) const
inline

Definition at line 382 of file Term.h.

static size_t Term::getFirstNonZeroExponent ( const Exponent a,
size_t  varCount 
)
inlinestatic

Returns least var such that a[var] is non-zero.

Returns varCount if the entries of a are all zero.

Definition at line 338 of file Term.h.

size_t Term::getFirstNonZeroExponent ( ) const
inline

Definition at line 346 of file Term.h.

static size_t Term::getHashCode ( const Exponent a,
size_t  varCount 
)
inlinestatic

Definition at line 416 of file Term.h.

size_t Term::getHashCode ( ) const
inline

Definition at line 423 of file Term.h.

size_t Term::getMaxExponent ( ) const
inline

Definition at line 386 of file Term.h.

static size_t Term::getMiddleNonZeroExponent ( const Exponent a,
size_t  varCount 
)
inlinestatic

Returns a median element of the set of var's such that a[var] is non-zero.

Returns varCount is the entries of a are all zero.

Definition at line 353 of file Term.h.

size_t Term::getMiddleNonZeroExponent ( ) const
inline

Definition at line 368 of file Term.h.

static size_t Term::getSizeOfSupport ( const Exponent a,
size_t  varCount 
)
inlinestatic

Returns the number of variables $x_i$ such that $x_i$ divides $a$.

Definition at line 394 of file Term.h.

size_t Term::getSizeOfSupport ( ) const
inline

Definition at line 403 of file Term.h.

size_t Term::getVarCount ( ) const
inline

Definition at line 85 of file Term.h.

static bool Term::hasSameSupport ( const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Returns whether $x_i|a\Leftrightarrow x_i|b$ for every variable $x_i$.

Definition at line 438 of file Term.h.

bool Term::hasSameSupport ( const Term a) const
inline

Definition at line 455 of file Term.h.

bool Term::hasSameSupport ( const Exponent a) const
inline

Definition at line 460 of file Term.h.

void Term::initialize ( const Exponent exponents,
size_t  varCount 
)
inlineprivate

Definition at line 579 of file Term.h.

static bool Term::isIdentity ( const Exponent a,
size_t  varCount 
)
inlinestatic

Returns whether a is 1, i.e. whether all entries of a are 0.

Definition at line 308 of file Term.h.

bool Term::isIdentity ( ) const
inline

Definition at line 316 of file Term.h.

static bool Term::isSquareFree ( const Exponent a,
size_t  varCount 
)
inlinestatic

Returns whether a is square free, i.e. $v_i\leq 1$ for each $i$ where $a=x^v$.

Definition at line 323 of file Term.h.

bool Term::isSquareFree ( ) const
inline

Definition at line 331 of file Term.h.

static void Term::lcm ( Exponent res,
const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Sets res equal to the least commom multiple of a and b.

Definition at line 213 of file Term.h.

void Term::lcm ( const Term a,
const Term b,
int  position 
)
inline

Definition at line 227 of file Term.h.

void Term::lcm ( const Term a,
const Term b 
)
inline

Definition at line 236 of file Term.h.

void Term::lcm ( const Exponent a,
const Exponent b 
)
inline

Definition at line 242 of file Term.h.

Term::operator const Exponent * ( ) const
inline

Definition at line 77 of file Term.h.

Term::operator Exponent * ( )
inline

Definition at line 76 of file Term.h.

bool Term::operator!= ( const Term term) const
inline

Definition at line 122 of file Term.h.

bool Term::operator!= ( const Exponent term) const
inline

Definition at line 123 of file Term.h.

Term& Term::operator= ( const Term term)
inline

Definition at line 125 of file Term.h.

Term& Term::operator= ( const Exponent exponents)
inline

Definition at line 137 of file Term.h.

bool Term::operator== ( const Term term) const
inline

Definition at line 117 of file Term.h.

bool Term::operator== ( const Exponent term) const

Definition at line 128 of file Term.cpp.

Exponent Term::operator[] ( int  offset) const
inline

Definition at line 89 of file Term.h.

Exponent Term::operator[] ( unsigned int  offset) const
inline

Definition at line 94 of file Term.h.

Exponent Term::operator[] ( unsigned long  offset) const
inline

Definition at line 98 of file Term.h.

Exponent& Term::operator[] ( int  offset)
inline

Definition at line 103 of file Term.h.

Exponent& Term::operator[] ( unsigned int  offset)
inline

Definition at line 108 of file Term.h.

Exponent& Term::operator[] ( unsigned long  offset)
inline

Definition at line 112 of file Term.h.

void Term::print ( FILE *  file,
const Exponent e,
size_t  varCount 
)
static

Writes e to file in a format suitable for debug output.

Definition at line 110 of file Term.cpp.

void Term::print ( ostream &  out,
const Exponent e,
size_t  varCount 
)
static

Writes e to out in a format suitable for debug output.

Definition at line 116 of file Term.cpp.

void Term::print ( FILE *  file) const
inline

Definition at line 566 of file Term.h.

void Term::print ( ostream &  out) const
inline

Definition at line 570 of file Term.h.

static void Term::product ( Exponent res,
const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Sets res equal to the product of a and b.

Definition at line 272 of file Term.h.

void Term::product ( const Term a,
const Term b 
)
inline

Set this object equal to the product of a and b.

Definition at line 283 of file Term.h.

void Term::product ( const Exponent a,
const Exponent b 
)
inline

Definition at line 289 of file Term.h.

void Term::reset ( size_t  newVarCount)
inline

Definition at line 543 of file Term.h.

static void Term::setToIdentity ( Exponent res,
size_t  varCount 
)
inlinestatic

Set res equal to $1=x^{(0,\ldots,0)}$, i.e. set each entry of res equal to 0.

Definition at line 296 of file Term.h.

void Term::setToIdentity ( )
inline

Definition at line 302 of file Term.h.

static bool Term::sharesNonZeroExponent ( const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Returns whether there is some $i$ such that $a_i=b_i>0$.

Definition at line 408 of file Term.h.

bool Term::sharesNonZeroExponent ( const Exponent a) const
inline

Definition at line 427 of file Term.h.

bool Term::sharesNonZeroExponent ( const Term a) const
inline

Definition at line 431 of file Term.h.

static bool Term::strictlyDivides ( const Exponent a,
const Exponent b,
size_t  varCount 
)
inlinestatic

Returns whether a strictly divides b.

$a$ strictly divides $b$ if $a * gcd(a, x_1...x_n)$ divides $b$ and $b\neq 1$, i.e. if, for each $i$, $u_i<b_i$ or $v_i=0$ where $a=x^u$, $b=x^v\neq x^0$.

Definition at line 188 of file Term.h.

bool Term::strictlyDivides ( const Term term) const
inline

Definition at line 203 of file Term.h.

bool Term::strictlyDivides ( const Exponent term) const
inline

Definition at line 208 of file Term.h.

void Term::swap ( Term term)
inline

Definition at line 535 of file Term.h.

Member Data Documentation

Exponent* Term::_exponents
private

Definition at line 589 of file Term.h.

size_t Term::_varCount
private

Definition at line 590 of file Term.h.


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