Class AsyCost::AsyCostEntry

Nested Relationships

This class is a nested type of Class AsyCost.

Class Documentation

class AsyCostEntry

A single term of an AsyCost: a rational prefactor times a product of index-space sizes raised to per-space exponents, e.g. 3/2 * O^2 V^4.

Public Functions

AsyCostEntry()

Constructors.

AsyCostEntry(AsyCostEntry const&) = default
AsyCostEntry(AsyCostEntry&&) = default
AsyCostEntry(ExponentMap exponents, rational prefactor)
Parameters:
  • exponents – Map from index space to its exponent. Zero exponents are dropped.

  • prefactor – Rational multiplier. If it is zero, or no exponents remain after dropping zeros, the entry collapses to zero.

AsyCostEntry &operator=(AsyCostEntry const&) = default
AsyCostEntry &operator=(AsyCostEntry&&) = default
ExponentMap const &exponents() const
Returns:

The per-space exponents of this term.

rational prefactor() const
Returns:

The rational multiplier (prefactor) of this term, e.g. 3/2 in 3/2 * O^2 V^4.

void set_prefactor(rational n) const

Set the rational multiplier. const because the prefactor is not part of the term’s identity (see operator==).

bool is_zero() const
Returns:

Whether this is the zero entry.

bool is_max() const
Returns:

Whether this is the max() sentinel.

bool operator<(AsyCostEntry const &rhs) const

Order by the max() sentinel (greatest), then by total polynomial degree (sum of exponents), then space by space from highest- to lowest-priority IndexSpace. Independent of the prefactor.

bool operator==(AsyCostEntry const &rhs) const
Returns:

Whether two entries share the same monomial (same exponents and max-ness). The prefactor is not compared.

bool operator!=(AsyCostEntry const &rhs) const
std::string text() const
Returns:

A plain-text rendering of this term, e.g. 3/2*O^2V^4.

std::string to_latex() const
Returns:

A LaTeX rendering of this term.

Public Static Functions

static std::ostream &stream_out_rational(std::ostream &os, rational const &r)

Write a rational to a stream as num, or num/den when its denominator is not 1.

Parameters:
  • os – Stream to write to.

  • r – Rational to format

Returns:

os

static AsyCostEntry max()
Returns:

The sentinel entry representing an infinitely scaling cost; it compares greater than every non-max entry.

static AsyCostEntry const &zero()
Returns:

The canonical zero entry (no exponents, zero prefactor).