Monomial

Monomials are ordered products of algebra generators. Even though monomials stored as parts of a polynomial expression are always canonically ordered, that need not be true in general.

template<typename ...IndexTypes>
class monomial

Monomial, an ordered product of zero or more algebra generators \(g_{i_1}, g_{i_2}, \ldots, g_{i_n}\),

\[M^{(n)}_{i_1, i_2, \ldots, i_n} = g_{i_1} g_{i_2} \ldots g_{i_n}.\]

IndexTypes - types of indices carried by the algebra generators.

Member type aliases

using index_types = std::tuple<IndexTypes...>
using generator_type = generator<IndexTypes...>
using gen_ptr_type = std::unique_ptr<generator_type>

Constructors

monomial() = default

Construct an empty (zero-length) monomial \(M^{(0)} = 1\).

template<typename ...GenTypes>
explicit monomial(GenTypes&&... generators)

Construct a non-empty monomial from a list of generators.

monomial(std::initializer_list<generator_type*> generators)

Construct a monomial from a list of pointers to generators using the list initialization syntax. This constructor creates copies of the generators by calling generator::clone().

monomial(std::vector<generator_type*> generators)

Construct a monomial from a vector of pointers to generators. This constructor creates copies of the generators by calling generator::clone().

monomial(std::initializer_list<gen_ptr_type> generators)

Construct a monomial from a list of smart pointers to generators using the list initialization syntax. This constructor creates copies of the generators by calling generator::clone().

Copy/move-constructors and assignments

monomial(monomial const &m)
monomial(monomial&&) noexcept = default
monomial &operator=(monomial const &m)
monomial &operator=(monomial&&) noexcept = default

Iteration interface

class const_iterator

Random access constant iterator to the list of algebra generators. The dereference type is generator_type.

const_iterator begin() const noexcept
const_iterator cbegin() const noexcept

Constant iterator to the first algebra generator.

const_iterator end() const noexcept
const_iterator cend() const noexcept

Constant past-the-end iterator.

using const_reverse_iterator = std::reverse_iterator<const_iterator>

Reverse iteration version of const_iterator.

const_reverse_iterator rbegin() const noexcept
const_reverse_iterator crbegin() const noexcept

Reverse constant iterator to last algebra generator.

const_reverse_iterator rend() const noexcept
const_reverse_iterator crend() const noexcept

Reverse constant past-the-end iterator.

generator_type const &operator[](std::size_t n) const

Access an algebra generator by its position n in the monomial.

Other methods and friend functions

std::size_t size() const

Number of algebra generators in the monomial.

bool empty() const

Is this a zero-length monomial?

friend bool operator==(monomial const &m1, monomial const &m2)
friend bool operator!=(monomial const &m1, monomial const &m2)
friend bool operator<(monomial const &m1, monomial const &m2)
friend bool operator>(monomial const &m1, monomial const &m2)

Compare two monomials. The lesser and greater comparisons check monomials’ lengths first, and in the case of equal lengths perform the lexicographical comparison of the generator lists.

bool is_ordered() const

Is this monomial canonically ordered? In other words, does its algebra generator list satisfy \(g_{i_1} < g_{i_2} < \ldots < g_{i_n}\)?

void swap_generators(std::size_t n1, std::size_t n2)

Swap algebra generators at positions n1 and n2 within the list.

void append(generator_type const &g)
void append(monomial const &m)
void append(std::pair<const_iterator, const_iterator> const &r)

Append a generator, a monomial or a range of generators specified by a begin-end iterator pair std::pair<const_iterator, const_iterator> to this monomial.

template<typename ...PartTypes>
friend monomial concatenate(PartTypes&&... parts)

Concatenate a number of parts to build a new monomial. The parts can be monomials, algebra generators and ranges within monomials. The ranges should be passed as begin-end iterator pairs std::pair<const_iterator, const_iterator>.

friend std::ostream &operator<<(std::ostream &os, monomial const &m)

Output stream insertion operator.