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.
| Term (const string &str)
| Accepts a whitespace-separated list of integers as exponent vector.
| ~Term ()
| operator Exponent * ()
| operator const Exponent * () const
Exponent * | begin ()
const Exponent * | begin () const
Exponent * | end ()
const Exponent * | end () const
size_t | getVarCount () const
Exponent | operator[] (int offset) const
Exponent | operator[] (unsigned int offset) const
Exponent | operator[] (unsigned long offset) const
Exponent | operator[] (unsigned long long offset) const
Exponent & | operator[] (int offset)
Exponent & | operator[] (unsigned int offset)
Exponent & | operator[] (unsigned long offset)
Exponent & | operator[] (unsigned long 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
Term & | operator= (const Term &term)
Term & | operator= (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.
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.
static bool | dominates (const Exponent *a, const Exponent *b, size_t varCount)
| Returns whether a dominates b, i.e. whether b divides a.
static bool | strictlyDivides (const Exponent *a, const Exponent *b, size_t varCount)
| Returns whether a strictly divides b.
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.
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.
static void | product (Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
| Sets res equal to the product of a and b.
static void | setToIdentity (Exponent *res, size_t varCount)
| Set res equal to , i.e. set each entry of res equal to 0.
static bool | isIdentity (const Exponent *a, size_t varCount)
| Returns whether a is 1, i.e. whether all entries of a are 0.
static bool | isSquareFree (const Exponent *a, size_t varCount)
| Returns whether a is square free, i.e. for each where .
static size_t | getFirstNonZeroExponent (const Exponent *a, size_t varCount)
| Returns least var such that a[var] is non-zero.
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.
static size_t | getFirstMaxExponent (const Exponent *a, size_t varCount)
| Returns a var such that a[var] >= a[i] for all i.
static size_t | getSizeOfSupport (const Exponent *a, size_t varCount)
| Returns the number of variables such that divides .
static bool | sharesNonZeroExponent (const Exponent *a, const Exponent *b, size_t varCount)
| Returns whether there is some such that .
static size_t | getHashCode (const Exponent *a, size_t varCount)
static bool | hasSameSupport (const Exponent *a, const Exponent *b, size_t varCount)
| Returns whether for every variable .
static void | colon (Exponent *res, const Exponent *a, const Exponent *b, size_t varCount)
| Sets res equal to .
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.
static void | decrement (Exponent *a, size_t varCount)
| Decrements each positive entry of a by one.
static void | print (FILE *file, const Exponent *e, size_t varCount)
| Writes e to file in a format suitable for debug output.
static void | print (ostream &out, const Exponent *e, size_t varCount)
| Writes e to out in a format suitable for debug output.

## Private Member Functions

void | initialize (const Exponent *exponents, size_t varCount)

## Static Private Member Functions

static Exponent * | allocate (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() [1/5]

Term::Term | ( |  | ) |

inline

Definition at line 51 of file Term.h.

## Term() [2/5]

Term::Term | ( | const Term & | term | ) |

inline

Definition at line 52 of file Term.h.

## Term() [3/5]

Term::Term | ( | const Exponent * | exponents,
|  | size_t | varCount )

inline

Definition at line 53 of file Term.h.

## Term() [4/5]

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() [5/5]

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::~Term | ( |  | ) |

inline

Definition at line 74 of file Term.h.

## Member Function Documentation

## allocate()

Exponent * Term::allocate | ( | size_t | size | ) |

static private

Definition at line 86 of file Term.cpp.

## begin() [1/2]

Exponent * Term::begin | ( |  | ) |

inline

Definition at line 79 of file Term.h.

## begin() [2/2]

const Exponent * Term::begin | ( |  | ) | const

inline

Definition at line 80 of file Term.h.

## clear()

void Term::clear | ( |  | ) |

inline

Definition at line 562 of file Term.h.

## colon() [1/3]

void Term::colon | ( | const Exponent * | a,
|  | const Exponent * | b )

inline

Definition at line 496 of file Term.h.

## colon() [2/3]

void Term::colon | ( | const Term & | a,
|  | const Term & | b )

inline

Definition at line 490 of file Term.h.

## colon() [3/3]

void Term::colon | ( | Exponent * | res,
|  | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

Sets res equal to .

is read as "a colon b", and it is defined as .

Definition at line 476 of file Term.h.

## deallocate()

void Term::deallocate | ( | Exponent * | p,
|  | size_t | size )

static private

Definition at line 98 of file Term.cpp.

## decrement() [1/2]

void Term::decrement | ( |  | ) |

inline

Definition at line 539 of file Term.h.

## decrement() [2/2]

void Term::decrement | ( | Exponent * | a,
|  | size_t | varCount )

inline static

Decrements each positive entry of a by one.

Definition at line 532 of file Term.h.

## divides() [1/3]

bool Term::divides | ( | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

Returns whether a divides b.

Definition at line 152 of file Term.h.

## divides() [2/3]

bool Term::divides | ( | const Exponent * | term | ) | const

inline

Definition at line 166 of file Term.h.

## divides() [3/3]

bool Term::divides | ( | const Term & | term | ) | const

inline

Definition at line 161 of file Term.h.

## dominates() [1/3]

bool Term::dominates | ( | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

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

Definition at line 172 of file Term.h.

## dominates() [2/3]

bool Term::dominates | ( | const Exponent * | term | ) | const

inline

Definition at line 187 of file Term.h.

## dominates() [3/3]

bool Term::dominates | ( | const Term & | term | ) | const

inline

Definition at line 182 of file Term.h.

## encodedDual() [1/3]

void Term::encodedDual | ( | const Exponent * | dualOf,
|  | const Exponent * | point )

inline

Definition at line 527 of file Term.h.

## encodedDual() [2/3]

void Term::encodedDual | ( | const Term & | dualOf,
|  | const Term & | point )

inline

Definition at line 521 of file Term.h.

## encodedDual() [3/3]

void Term::encodedDual | ( | Exponent * | res,
|  | const Exponent * | dualOf,
|  | const Exponent * | point,
|  | size_t | varCount )

inline static

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 505 of file Term.h.

## end() [1/2]

Exponent * Term::end | ( |  | ) |

inline

Definition at line 82 of file Term.h.

## end() [2/2]

const Exponent * Term::end | ( |  | ) | const

inline

Definition at line 83 of file Term.h.

## gcd() [1/3]

void Term::gcd | ( | const Exponent * | a,
|  | const Exponent * | b )

inline

Definition at line 275 of file Term.h.

## gcd() [2/3]

void Term::gcd | ( | const Term & | a,
|  | const Term & | b )

inline

Definition at line 269 of file Term.h.

## gcd() [3/3]

void Term::gcd | ( | Exponent * | res,
|  | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

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

Definition at line 255 of file Term.h.

## getFirstMaxExponent() [1/2]

size_t Term::getFirstMaxExponent | ( |  | ) | const

inline

Definition at line 390 of file Term.h.

## getFirstMaxExponent() [2/2]

size_t Term::getFirstMaxExponent | ( | const Exponent * | a,
|  | size_t | varCount )

inline static

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

Definition at line 381 of file Term.h.

## getFirstNonZeroExponent() [1/2]

size_t Term::getFirstNonZeroExponent | ( |  | ) | const

inline

Definition at line 354 of file Term.h.

## getFirstNonZeroExponent() [2/2]

size_t Term::getFirstNonZeroExponent | ( | const Exponent * | a,
|  | size_t | varCount )

inline static

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

Returns varCount if the entries of a are all zero.

Definition at line 346 of file Term.h.

## getHashCode() [1/2]

size_t Term::getHashCode | ( |  | ) | const

inline

Definition at line 431 of file Term.h.

## getHashCode() [2/2]

size_t Term::getHashCode | ( | const Exponent * | a,
|  | size_t | varCount )

inline static

Definition at line 424 of file Term.h.

## getMaxExponent()

size_t Term::getMaxExponent | ( |  | ) | const

inline

Definition at line 394 of file Term.h.

## getMiddleNonZeroExponent() [1/2]

size_t Term::getMiddleNonZeroExponent | ( |  | ) | const

inline

Definition at line 376 of file Term.h.

## getMiddleNonZeroExponent() [2/2]

size_t Term::getMiddleNonZeroExponent | ( | const Exponent * | a,
|  | size_t | varCount )

inline static

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 361 of file Term.h.

## getSizeOfSupport() [1/2]

size_t Term::getSizeOfSupport | ( |  | ) | const

inline

Definition at line 411 of file Term.h.

## getSizeOfSupport() [2/2]

size_t Term::getSizeOfSupport | ( | const Exponent * | a,
|  | size_t | varCount )

inline static

Returns the number of variables such that divides .

Definition at line 402 of file Term.h.

## getVarCount()

size_t Term::getVarCount | ( |  | ) | const

inline

Definition at line 85 of file Term.h.

## hasSameSupport() [1/3]

bool Term::hasSameSupport | ( | const Exponent * | a | ) | const

inline

Definition at line 468 of file Term.h.

## hasSameSupport() [2/3]

bool Term::hasSameSupport | ( | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

Returns whether for every variable .

Definition at line 446 of file Term.h.

## hasSameSupport() [3/3]

bool Term::hasSameSupport | ( | const Term & | a | ) | const

inline

Definition at line 463 of file Term.h.

## initialize()

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

inline private

Definition at line 587 of file Term.h.

## isIdentity() [1/2]

bool Term::isIdentity | ( |  | ) | const

inline

Definition at line 324 of file Term.h.

## isIdentity() [2/2]

bool Term::isIdentity | ( | const Exponent * | a,
|  | size_t | varCount )

inline static

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

Definition at line 316 of file Term.h.

## isSquareFree() [1/2]

bool Term::isSquareFree | ( |  | ) | const

inline

Definition at line 339 of file Term.h.

## isSquareFree() [2/2]

bool Term::isSquareFree | ( | const Exponent * | a,
|  | size_t | varCount )

inline static

Returns whether a is square free, i.e. for each where .

Definition at line 331 of file Term.h.

## lcm() [1/4]

void Term::lcm | ( | const Exponent * | a,
|  | const Exponent * | b )

inline

Definition at line 250 of file Term.h.

## lcm() [2/4]

void Term::lcm | ( | const Term & | a,
|  | const Term & | b )

inline

Definition at line 244 of file Term.h.

## lcm() [3/4]

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

inline

Definition at line 235 of file Term.h.

## lcm() [4/4]

void Term::lcm | ( | Exponent * | res,
|  | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

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

Definition at line 221 of file Term.h.

## operator const Exponent *()

Term::operator const Exponent * | ( |  | ) | const

inline

Definition at line 77 of file Term.h.

## operator Exponent *()

Term::operator Exponent * | ( |  | ) |

inline

Definition at line 76 of file Term.h.

## operator!=() [1/2]

bool Term::operator!= | ( | const Exponent * | term | ) | const

inline

Definition at line 131 of file Term.h.

## operator!=() [2/2]

bool Term::operator!= | ( | const Term & | term | ) | const

inline

Definition at line 130 of file Term.h.

## operator=() [1/2]

Term & Term::operator= | ( | const Exponent * | exponents | ) |

inline

Definition at line 145 of file Term.h.

## operator=() [2/2]

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

inline

Definition at line 133 of file Term.h.

## operator==() [1/2]

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

Definition at line 128 of file Term.cpp.

## operator==() [2/2]

bool Term::operator== | ( | const Term & | term | ) | const

inline

Definition at line 125 of file Term.h.

## operator[]() [1/8]

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

inline

Definition at line 107 of file Term.h.

## operator[]() [2/8]

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

inline

Definition at line 89 of file Term.h.

## operator[]() [3/8]

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

inline

Definition at line 112 of file Term.h.

## operator[]() [4/8]

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

inline

Definition at line 94 of file Term.h.

## operator[]() [5/8]

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

inline

Definition at line 120 of file Term.h.

## operator[]() [6/8]

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

inline

Definition at line 102 of file Term.h.

## operator[]() [7/8]

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

inline

Definition at line 116 of file Term.h.

## operator[]() [8/8]

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

inline

Definition at line 98 of file Term.h.

## print() [1/4]

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

inline

Definition at line 574 of file Term.h.

## print() [2/4]

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.

## print() [3/4]

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

inline

Definition at line 578 of file Term.h.

## print() [4/4]

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.

## product() [1/3]

void Term::product | ( | const Exponent * | a,
|  | const Exponent * | b )

inline

Definition at line 297 of file Term.h.

## product() [2/3]

void Term::product | ( | const Term & | a,
|  | const Term & | b )

inline

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

Definition at line 291 of file Term.h.

## product() [3/3]

void Term::product | ( | Exponent * | res,
|  | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

Sets res equal to the product of a and b.

Definition at line 280 of file Term.h.

## reset()

void Term::reset | ( | size_t | newVarCount | ) |

inline

Definition at line 551 of file Term.h.

## setToIdentity() [1/2]

void Term::setToIdentity | ( |  | ) |

inline

Definition at line 310 of file Term.h.

## setToIdentity() [2/2]

void Term::setToIdentity | ( | Exponent * | res,
|  | size_t | varCount )

inline static

Set res equal to , i.e. set each entry of res equal to 0.

Definition at line 304 of file Term.h.

## sharesNonZeroExponent() [1/3]

bool Term::sharesNonZeroExponent | ( | const Exponent * | a | ) | const

inline

Definition at line 435 of file Term.h.

## sharesNonZeroExponent() [2/3]

bool Term::sharesNonZeroExponent | ( | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

Returns whether there is some such that .

Definition at line 416 of file Term.h.

## sharesNonZeroExponent() [3/3]

bool Term::sharesNonZeroExponent | ( | const Term & | a | ) | const

inline

Definition at line 439 of file Term.h.

## strictlyDivides() [1/3]

bool Term::strictlyDivides | ( | const Exponent * | a,
|  | const Exponent * | b,
|  | size_t | varCount )

inline static

Returns whether a strictly divides b.

strictly divides if divides and , i.e. if, for each , or where , .

Definition at line 196 of file Term.h.

## strictlyDivides() [2/3]

bool Term::strictlyDivides | ( | const Exponent * | term | ) | const

inline

Definition at line 216 of file Term.h.

## strictlyDivides() [3/3]

bool Term::strictlyDivides | ( | const Term & | term | ) | const

inline

Definition at line 211 of file Term.h.

## swap()

void Term::swap | ( | Term & | term | ) |

inline

Definition at line 543 of file Term.h.

## Member Data Documentation

## _exponents

Exponent* Term::_exponents

private

Definition at line 597 of file Term.h.

## _varCount

size_t Term::_varCount

private

Definition at line 598 of file Term.h.

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

- src/Term.h
- src/Term.cpp