Class AsyCost¶
Defined in File asy_cost.hpp
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
class AsyCost¶
Represents a symbolic asymptotic cost as a polynomial in the sizes of bases of index spaces. A cost is a sum of terms, each of which is a rational multiplier times a product of basis sizes raised to non-negative integer powers. Bases are identified by
IndexBasis, so each basis instance of a space is a symbol of its own;AsyCostorders them usingIndexBasis’s own ordering (a space’s own basis orders as the space), prints a space’s own basis by itsbase_key(), a named basis instance by its name and an unnamed one asbase_key()<;N>, and never consults anIndexBasisRegistry.Examples (with
I,Adenoting two index spaces):AsyCost({{I, 2}, {A, 4}})represents $I^2 A^4$.AsyCost({{I, 2}, {A, 4}}, rational{1, 2})halves the numeric value above when extents are substituted.
Public Types
-
using ExponentMap = container::map<IndexBasis, std::size_t>¶
-
using ExtentMap = container::map<IndexBasis, std::size_t>¶
Public Functions
-
AsyCost()¶
Default construct to zero cost.
-
explicit AsyCost(ExponentMap exponents, rational prefactor = 1)¶
- Parameters:
exponents – Map from basis to its exponent in this term. Zero exponents may be supplied; they are dropped.
prefactor – Rational multiplier; defaults to 1.
-
double ops(ExtentMap const &extents = {}) const¶
Substitute each basis in this cost by an extent and evaluate.
- Parameters:
extents – Map from basis to extent (size). A basis appearing in this cost but absent from
extentsfalls back to itsIndexBasis::extent()(the dimension of its space, or for a named basis instance obtained from the registry the extent it was registered with). Defaults to empty, in which case every basis uses that extent.- Returns:
Numerical value of the cost.
-
std::wstring to_latex() const¶
- Returns:
A LaTeX rendering of the whole cost: its terms joined by
+, most expensive first. The zero cost renders as0.
-
std::string text() const¶
- Returns:
A plain-text rendering of the whole cost: its terms joined by
+, most expensive first. The zero cost renders as0.
Public Static Functions
Friends